使用.htaccess删除我的index.php文件

使用.htaccess删除我的index.php文件,.htaccess,.htaccess,我正在尝试使用.htaccess文件和以下代码删除主站点上的trailing index.php RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.(html?|php[45]?|[aj]spx?)\ HTTPS/ RewriteRule index\.(html?|php[45]?|[aj]spx?)$ https://www.gekkodev.com/%1 [R=301,L] 但当然它仍然不起作用!我认为问题在于我的ssl

我正在尝试使用.htaccess文件和以下代码删除主站点上的trailing index.php

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.(html?|php[45]?|[aj]spx?)\ HTTPS/
RewriteRule index\.(html?|php[45]?|[aj]spx?)$ https://www.gekkodev.com/%1 [R=301,L]
但当然它仍然不起作用!我认为问题在于我的ssl证书,因为该代码在许多其他网站上都运行良好

任何想法都会被接受! 非常感谢

  • 菲利普

您的
RewriteCond
采取了完全错误的方法。HTTPS请求只是一个用SSL/TLS安全性包装的HTTP请求,它不会在请求行中包含字符串
HTTPS
,这就是您要检查的内容

如果希望规则仅适用于HTTPS请求,只需使用
%{HTTPS}
变量,如下所示:


(我最近看到很多重写规则测试
%{THE_REQUEST}
,我不知道为什么,因为它实际上只应该在没有其他方法可以工作的情况下作为最后手段使用。)

我就是这样做的

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule index\.(html?|php[45]?|[aj]spx?)$ https://www.gekkodev.com/%1 [R=301,L]

干杯IMSoP

它在做什么而不是工作?是否重定向错误?这根本不是重写吗?您使用的输入URL示例是什么?
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule index\.(html?|php[45]?|[aj]spx?)$ https://www.gekkodev.com/%1 [R=301,L]