我想重定向以下内容:
http://example.com
到 https://www.example.com
http://www.example.com
到 https://www.example.com
https://example.com
到 https://www.example.com
“ www.example.com”到https://www.example.com
您可以将这些mod_rewrite
规则添加到.htaccess
站点根目录的文件中:
RewriteEngine On
RewriteBase /
# www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
请注意,您将需要mod_rewrite
启用模块。另外,您可能需要.htaccess
在Apache配置中调整权限/覆盖。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句