繁体   English   中英

使用mod_rewrite完全删除index.php

[英]Using mod_rewrite to remove index.php completely


我正在寻找一种方法来从URL中删除任何为index.php的文件名。 我想尝试执行此操作的主要原因是因为我的目录中包含“ index.php”。 所以没有得到...
http:// localhost / members / index /
我希望能实现更多...
http:// localhost / members /

下面的代码当前是我的.htaccess文件中的代码。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]

我非常感谢您的帮助和任何建议! 非常感谢,上帝保佑!

如果您要做的只是从URL中“删除” index.php,则只需确保Apache知道index.php可用作目录索引。

DirectoryIndex index.php

您可以将其放在您的Apache配置,VirtualHost或.htaccess文件中。

只需使用此:

RewriteCond %{THE_REQUEST} ^.*index.php.*

而已 ;)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM