Php htaccess中DirectoryIndex的正则表达式
抱歉,如果我重复了一些关于.htaccess的讨论。但我没有找到我的问题的直接答案。 这是: 1.我正在尝试从主目录和子目录中的URL中删除index.php。 到目前为止,我已经掌握了以下两条规则(一条用于主目录,另一条用于子目录): 有没有一种方法可以用一个共同的规则做到这一点Php htaccess中DirectoryIndex的正则表达式,php,apache,.htaccess,Php,Apache,.htaccess,抱歉,如果我重复了一些关于.htaccess的讨论。但我没有找到我的问题的直接答案。 这是: 1.我正在尝试从主目录和子目录中的URL中删除index.php。 到目前为止,我已经掌握了以下两条规则(一条用于主目录,另一条用于子目录): 有没有一种方法可以用一个共同的规则做到这一点 我还有很多子目录索引文件,它们的前缀以-index结尾: bla索引、foo索引、前缀索引等。我想使用某种正则表达式使它们都作为DirectoryIndex工作。 以下规则删除prefix-index.php #re
#removes prefix-index.php (in all directories exept public_html)
RewriteRule ^(.*)/(.*)index.php /$1 [R=301,R]
DirectoryIndex index.php
我尝试了不同的DirectoryIndex正则表达式,但没有成功。请帮忙
另外,我只能使用htaccess而不能使用httpd.conf。您可以在站点根目录中使用此代码删除
index.php
。htaccess:
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} \s(.*)index\.php[?\s] [NC]
RewriteRule ^ %1 [L,R=301,NE]
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} \s(.*)index\.php[?\s] [NC]
RewriteRule ^ %1 [L,R=301,NE]