Reputation: 61
I'm trying to 301 redirect
to
and tried:
redirect 301 /page.html http://subdomain.domain.com/page.html
The problem is both the domain and the subdomain are pointed to the same dir and that makes the redirect in a way that will never complete.
also tried with no success:
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^page\.html$ "http\:\/\/subdomain\.domain\.com\/page\.html" [R=301,L]
Upvotes: 3
Views: 493
Reputation: 61
ok...I figured this out - the second case works - just needs to be placed right after RewriteEngine On:
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^page.html$ http://subdomain.domain.com/page.html [R=301,L]
and this could be used for multiple rules under one condition:
RewriteCond %{HTTP_HOST} !^(www\.)?domain.com$ [NC]
RewriteRule .* - [S=2]
RewriteRule ^page.html$ http://subdomain.domain.com/page.html [R=301,L]
RewriteRule ^page-2.html$ http://subdomain.domain.com/page-2.html [R=301,L]
Upvotes: 1