Redirecting subdomain directory using htaccess
I am trying to redirect something like this
sub-domain.domain.com/directory to domain.com/directory
I tried Redirect 301 / domain.com / directory [htaccess file hosted on subdomain], it works fine for subdomain but won't work for directory inside subdomain.
Can someone help me with what should be the content of the .htaccess file?
Thank.
0
user183935
source
to share
1 answer
If you just want to redirect all requests from xxx.domain.com/yyy to www.domain.com/yyy, you can use:
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.domain/com/$1 [L,R]
Note. You will need to make sure the rewrite engine is enabled, etc.
Updated ..
If you just want 301, change [L, R] on the last line to [L, R = 301]
0
source to share