How to setup .htaccess to rewrite to different folder

Posted by Guy on Stack Overflow See other posts from Stack Overflow or by Guy
Published on 2010-03-29T09:46:40Z Indexed on 2010/03/29 10:03 UTC
Read the original article Hit count: 392

I'm moving my site to a new host but I need to have my current server continue to handle requests (not all files can be moved to the new server). So I added a parked domain to my old server (old.mydomain.com) and I want all requests to it to be written to the files from the old site.

My old site (mydomain.com) was hosted internally in a folder (/public_html/mydomain/) and I want all requests to old.mydomain.com to be rewritten to the same folder. So if mydomain.com/blog was internally at /public_html/mydomain/blog I now want old.mydomain.com/blog also to reach /public_html/mydomain/blog.

Here is the .htaccess that I'm trying to use:

RewriteCond %{HTTP_HOST} ^old\.mydomain\.com/*
RewriteRule ^(.*)$ mydomain/$1 [NC,L] 

but for some reason as soon as I add the $1 in the rewrite rule I get an internal error.

Any ideas?

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about mod-rewrite