We are migrating to a new server structure and I need some help with htaccess. I’m a php programmer and by no means an apache expert.
Here is the plain explanation:
-
I need the root directory of http://www.oldsite.com to redirect to the root directory http://www.newsite.com.
-
A specific directory http://www.oldsite/dir1 to redirect to a subdomain on the new site as in newdomain.newsite.com
-
Everything else http://www.oldsite.com/whatever/ needs to go to apps.newsite.com/whatever/
What I have right now is:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule / http://www.newsite.com [L,R=301]
RewriteRule (.*)dir1/ http://newdomain.newsite.com [L,R=301]
RewriteRule (.*)$ http://apps.newsite.com/$1 [L,R=301]
But its not working as I want it to…
Anyway, any and all help will be appreciated.
Thanks,
-Orallo
Using mod_alias, you can put this in either server/vhost config or in your htaccess file (in your document root of the oldsite.com):
As for mod_rewrite, you need to remove the leading slashes from your rewrite rules since you are using them in an htaccess file: