我的htaccess文件中有以下内容
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Block hidden directories
RewriteRule "(^|/)\." - [F]
# Prevent /health_check.php from using https
RewriteCond %{REQUEST_URI} !(health_check\.php)$
# Prevent /sns from using https but this DOES need codeigniter rewriting (see below)
RewriteCond %{REQUEST_URI} !^/(sns)/
# Reroute http to https
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# Prevent rewriting of domain for codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
我想做的是
重写codeigniter网址(包括/ sns)
将http请求转发给https(/health_check.php和/ sns除外)
阻止隐藏目录
这一切似乎都有效,除了/ sns仍然转发到https并更改为/index.php/sns
答案 0 :(得分:0)
将您的第二条规则更改为:
# Prevent /health_check.php from using https
RewriteCond %{THE_REQUEST} !/health_check\.php [NC]
# Prevent /sns from using https but this DOES need codeigniter rewriting (see below)
RewriteCond %{THE_REQUEST} !/sns [NC]
# Reroute http to https
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
THE_REQUEST
代替REQUEST_URI
作为最后规则会将REQUEST_URI
更改为/index.php
。