抱歉,我重复了一些关于.htaccess的讨论。但我没能直接回答我的问题。它们如下: 1.我试图从主目录和子目录中的URL中删除index.php。到目前为止,我已经讨论了以下两个规则(一个用于主目录,另一个用于子目录):
# removes index.php (in public_html)
RewriteRule ^index.php$ / [QSA,R]
# removes index.php (in all directories exept public_html)
RewriteRule ^(.*?)/index\.php /$1 [R=301,R]有什么办法可以用一个共同的规则来实现吗?
这正是我想要的,但现在我有了403错误,因为htaccess说:
DirectoryIndex index.php我为DirectoryIndex尝试过不同的正则表达式,但没有成功。请帮帮我!
我只能使用htaccess,而不能使用httpd.conf
发布于 2016-09-01 10:58:54
可以在站点根index.php中使用此代码删除.htaccess:
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} \s(.*)index\.php[?\s] [NC]
RewriteRule ^ %1 [L,R=301,NE]https://stackoverflow.com/questions/39232918
复制相似问题