Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Htaccess删除index.php?从URL_Php_.htaccess_Codeigniter - Fatal编程技术网

Htaccess删除index.php?从URL

Htaccess删除index.php?从URL,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,当我有一个配置了SSL的网站时,当使用HTTPS://访问该网站时,一切正常,但当我使用HTTP访问该网站时,我会在URL的末尾得到'index.php' 这是我的简历: RewriteEngine on RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png) RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-d Rewr

当我有一个配置了SSL的网站时,当使用HTTPS://访问该网站时,一切正常,但当我使用HTTP访问该网站时,我会在URL的末尾得到'index.php'

这是我的简历:

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

任何帮助都将不胜感激。

您的规则如下:

RewriteEngine on

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%1 [L,R=301,NE]

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

测试前,请确保在新浏览器中进行测试,或完全清除浏览器缓存。

规则如下:

RewriteEngine on

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%1 [L,R=301,NE]

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

在测试之前,请确保在新浏览器中对其进行测试或完全清除浏览器缓存。

以下命令强制使用https重写任何http请求。例如,以下代码强制加载请求。它还强制直接链接的资源(图像、css等)使用https

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

如果这不适合你,首先检查你的行尾。从web浏览器复制/粘贴到文本编辑器可能无法正常工作,因此在粘贴到文本编辑器后,应删除每个换行符并将其添加回(换行符=返回键)。

以下命令强制使用https重写任何http请求。例如,以下代码强制加载请求。它还强制直接链接的资源(图像、css等)使用https

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

如果这不适合你,首先检查你的行尾。从web浏览器复制/粘贴到文本编辑器可能无法正常工作,因此在粘贴到文本编辑器后,您应该删除每个换行符并将其添加回(换行符=返回键)。

i got as result domain.com/?/i got as result domain.com//