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