URL 将子文件夹中的所有 php 文件重写为 index.php

URL rewrite all php files in subfolder to index.php

我正在尝试设置一种方法,将子文件夹中的所有 php 文件重写为 index.php

到目前为止我一直在尝试的事情:

RewriteEngine on

RewriteBase /simple

RewriteRule ^(.+)/$ index.php

它不能 100% 工作,现在它也需要 CSS、IMG 和所有其他文件,它不应该,只有 PHP 文件。

希望有人能提供帮助。 谢谢。

RewriteRule ^(.+)\.php$ index.php就是这样

您可以使用:

DirectoryIndex index.php
RewriteEngine on
RewriteBase /simple/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

或这条规则:

RewriteRule !\.(js|ico|gif|jpe?g|png|css|html|swf|flv|xml)$ index.php [L,NC]