我正在尝试设置一种方法,将子文件夹中的所有php文件重写为index.php
到目前为止,我一直在尝试:
RewriteEngine on
RewriteBase /simple
RewriteRule ^(.+)/$ index.php
它不能100%工作,现在它也需要CSS、IMG和所有其他文件,而它不应该这样做,只需要PHP文件。
- 当我去http://localhost/simple/它加载正确
- 但当我去http://localhost/simple/test/所有的CSS和图像都没有加载,因为目录不存在
希望有人能帮忙。非常感谢。
您可以使用:
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]
RewriteRule ^(.+)'.php$ index.php
是