[英].htaccess rewrite to https
因此,我想执行以下操作:
如果用户尝试访问除index.php之外的网站的其他部分,则会将他们重定向到https版本。
因此,如果他们尝试转到example.com/index.php,则不会将其重定向到https版本
但是,如果它们转到除index.php之外的网站的任何部分(如welcome.php),它们将被重定向到https版本。
这是我之前进行完整站点https重定向的方式(我不确定如何对index.php上的https示例进行完整站点重定向)
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ https://www.handybook.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
为了使除索引以外的所有页面都重定向到https,请将以下内容添加到您的.htaccess文件中:
RewriteCond %{HTTPS} !on
RewriteRule !^(index)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}
您可以使用括号内的竖线字符添加其他例外,如下所示:
RewriteRule !^(index|about|contact)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.