Reputation: 16094
What I'm trying to achieve is a 301 redirection of all the pages/resources for a domain except the root of the site every page then should move from www.example.com/example.com to old.example.com.
I'm not an htaccess guru but this is the solution I came up with...
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteCond !^$ [NC]
RewriteRule ^(.*)$ http://old.example.com/$1 [R=301,L]
But seems not to work
Upvotes: 1
Views: 2016
Reputation: 9539
You were missing the TestString in the RewriteCond
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
#if not root
RewriteCond %{REQUEST_URI} !^/?$ [NC]
#redirect
RewriteRule ^(.*)$ http://old.example.com/$1 [R=301,L]
Upvotes: 2