Question

I'm trying to redirect www.olddomain.com/content/path to www.newdomain.com/content/path

Somehow:

.htaccess 301 redirect path and all child-paths

RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]

Isn't working and is always redirecting to index.

Thanks!

Était-ce utile?

La solution

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]

Autres conseils

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]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top