强制WWW preFIX用PHP / htaccess的/ mod_rewrite的 [英] Forcing the www prefix with PHP/htaccess/mod_rewrite
本文介绍了强制WWW preFIX用PHP / htaccess的/ mod_rewrite的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种简单的方法(preferably与htaccess以及mod_rewrite的),强制浏览器始终可以访问与WWW网站。 preFIX(自动将其添加必要?)
THX。
解决方案
的RewriteCond%{HTTP_HOST}!www.domain.com
重写规则^ /(。*)$ http://www.domain.com/$1 [R = 301]
或者
的RewriteCond%{HTTP_HOST}!^ WWW。
重写规则^ / $ HTTP(*)://www.% {HTTP_HOST} / $ 1 [R = 301]
Is there an easy way (preferably with htaccess and mod_rewrite) to force the browser to always access a site with the www. prefix (adding it automatically where necessary?)
Thx.
解决方案
Rewritecond %{HTTP_HOST} !www.domain.com
RewriteRule ^/(.*)$ http://www.domain.com/$1 [R=301]
or maybe
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^/(.*)$ http://www.%{HTTP_HOST}/$1 [R=301]
这篇关于强制WWW preFIX用PHP / htaccess的/ mod_rewrite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文