Frage

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!

War es hilfreich?

Lösung

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]

Andere Tipps

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]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top