htaccess的 - 重定向到www的所有非www交通
问题描述:
任何人都可以建议我如何让非WWW流量使用htaccess文件重定向到一个网站www的版本 - 我知道我有一个在我的根目录下创建的,但不能确定是什么把..任何想法。
Can anyone suggest how I get non www traffic to redirect to the www version of a website using the htaccess file - I know I have one created in my root directory but cannot be sure what to put.. any ideas
答
相对容易。
匹配任何不以WWW。然后重定向到WWW。版本:
Match anything that does not begin with 'www.' and then redirect to the 'www.' version:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]