To redirect all users to access the site WITH the ‘www.’ prefix,
(http://example.com/… will be redirected to http://www.example.com/…)
adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
将这段代码的最后两行中的example换成你的域名,并去掉前面的井号“#”注释,如本人插入.htaccess中的代码就是
RewriteCond %{HTTP_HOST} ^qh66.net$ [NC]
RewriteRule ^(.*)$ http://www.qh66.net/$1 [L,R=301]
如果你的域名是.com.cn的,一定要注意两个点都需要进行转义,即
RewriteCond %{HTTP_HOST} ^example.com.cn$ [NC]
RewriteRule ^(.*)$ http://www.example.com.cn/$1 [L,R=301]
————————————————
版权声明:本文为CSDN博主「阿贝快跑」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/linyiphp/article/details/79020952