.htaccess old domain to new domain 301 redirect, but only the domain, not it's pages
Let's say I have a domain: A.com
, and if someone goes to A.com
I want to redirect to B.com
.
But if they go to any page on A.com, e.g. A.com/wp-admin/index.php
, there will be NO redirect. In short, I just want a simple top level old name to new domain name 301 redirect. (Any specific pages on A.com will be red开发者_如何学JAVAirected to specific pages on B.com one by one).
Here you go:
RewriteEngine On
RewriteCond %{HTTP_HOST} =domain-one.com
RewriteRule ^$ http://domain-two.com/ [R=301,L]
This rule is to be placed in .htaccess in website root folder. If placed elsewhere some small tweaking may be required.
It will redirect hits to domain root only, e.g.
http://domain-one.com/
and no other pages.I have replaced
A.com
bydomain-one.com
andB.com
bydomain-two.com
-- it is more realistic/understandable thanA
&B
.
精彩评论