Reputation: 7077
I want to redirect test777.website.com
and all the pages inside it such as test77.website.com/blog
and test777.website.com/contact-us
to website.com
with 301 redirects.
I tried to do it with HTACCESS but wasnt successful. Can you please tell me the proper way to do this so google knows its not a 500 or 404 but a 301. Thanks
Upvotes: 0
Views: 28
Reputation: 42915
This should be what you are looking for:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test777\.example\.com$
RewriteRule ^(.*)$ https://example.com/$1 [R=301]
And a general hint: you should always prefer to place such rules into the http servers host configuration instead of relying on dynamic configuration files (".htaccess"). Reason is that those files are notoriously error prone, hard to debug and they really slow down the server, often for nothing. The mechanism to use such files is only provided as a last option for situations where you do not have control over the host configuration (read: really cheap hosting providers) and for applications that insist on writing their own redirection rules (which is an obvious security nightmare...).
Upvotes: 1