SSL inserts index.php的Codeigniter.htaccess文件
我正在使用以下.htaccess文件将某些页面重定向到SSL inserts index.php的Codeigniter.htaccess文件,.htaccess,codeigniter,ssl,.htaccess,Codeigniter,Ssl,我正在使用以下.htaccess文件将某些页面重定向到https:// RewriteEngine on RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} (sale|success|cancel) RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301] RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !(static
https://
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (sale|success|cancel)
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(static|sale|success|cancel)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301]
RewriteCond $1 !^(index\.php|resources|robots\.txt|static)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
这是可行的,除了当您转到被重写为https://
的页面时,它还会在URL中插入index.php
。一切正常,但我希望不要插入index.php
。有什么想法吗
谢谢。您缺少前两条规则中的
L
标志
您可以使用以下代码:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (sale|success|cancel) [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(static|sale|success|cancel) [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt|static) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
要求所有授权
***允许超越所有***
发展+标准
在apache配置中添加“AllowOverride All”后,它将正常工作
注意。在其他浏览器中测试以避免301缓存问题。
<Directory "/home/test">
Require all granted
***AllowOverride All***
SSLOptions +StdEnvVars
</Directory>