![使用.htaccess规范域名网址[去掉WWW或者添加WWW]](https://www.wentong.org/skin/wt/rpic/t22.jpg)
今天发现我的博客www.wentong.org网址还是被正常收录,其实我只喜欢不带www的网址,也就是wentong.org。还好,使用.htaccess规范域名网址就可以了:
去掉网址的www
#规范域名
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.wentong.org$
RewriteRule ^(.*)$ http://wentong.org/$1 [R=301,L]
把wentong.org换成你的域名就行了,下面修改方法相同。
让网址全部加上www
#规范域名
RewriteEngine on
RewriteCond %{HTTP_HOST} ^wentong.org$
RewriteRule ^(.*)$ http://www.wentong.org/$1 [R=301,L]
把其他网址重定向到新域名
#规范域名
RewriteEngine on
RewriteCond %{HTTP_HOST} ^其他域名.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.其他域名.com$
RewriteRule ^(.*)$ http://www.wentong.org/$1 [R=301,L]
把网址首页也规范一下
把index.html、index.php等重定向到index.php
#规范域名
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php HTTP/
RewriteRule ^index.php$ http://www.wentong.org/ [R=301,L]
检查一下是否成功
可以用这个免费工具检查一下转向的效果:
[anyad]
[url]http://www.internetofficer.com/seo-tool/redirect-check/[/url]
人吐槽 | 人点赞 |
发表评论