我希望获得以下2个页面来重定向www。各自主机的版本;
http://website.co.uk > redirect to > http://www.website.co.uk
和
https://website.co.uk > redirect to > https://www.website.co.uk
我需要使HTTP和HTTPs都适用于各自的URL。
您可以使用此单一规则增加www
两个http
和https
:
# for Apache 2.4+ use this rule
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ %{REQUEST_SCHEME}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
如果您使用的是Apache的旧版本,请使用以下规则:
# for Apache 2.2
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句