Reputation: 419
I'm trying to redirect www.olddomain.com/content/path to www.newdomain.com/content/path
Somehow:
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]
Isn't working and is always redirecting to index.
Thanks!
Upvotes: 4
Views: 5702
Reputation: 1
anubhava,
What would be the difference between:
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
OR you can do:
RewriteEngine On
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [L,R=301]
Upvotes: 0
Reputation: 785156
Because you're missing captured group $1
in target URL:
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
OR you can do:
RewriteEngine On
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [L,R=301]
Upvotes: 13