linux – Redirect 301 www.www.example.com
作者:互联网
我正在使用LAMP服务器,我需要重定向请求,如:
www.www.example.com到www.example.com和其他变体如(wwww.example.com等)
我知道我可以在.htaccess中完成它,但我不知道我应该用它来表示所有这些可能性的正则表达式.
或者有什么不同的方法,来自虚拟主机?
解决方法:
我喜欢:
# force www IN URL
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$http://www.example.com/$1 [R=301,L]
# END force www IN URL
基本上任何不是www.example.com的东西都会被重定向301’d.
标签:apache,linux,seo,http-status-code-301 来源: https://codeday.me/bug/20190527/1160559.html