添加异常后找不到.htaccess页



我有一个.htaccess文件,我想用它将configurationr.php以外的所有文件重写为index.php。这对我来说很好,使用以下代码:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/configurator [NC]
RewriteRule ^(.*)$ index.php?url=$1 [QSA]
RewriteRule ^([^.]+)$ $1.php [NC,L]

有了它,我就可以写";localhost/mypage/about us";并将其发送到索引页面。现在我想写一些类似";localhost/mypage/configurator/test";。但如果我这样做,我会得到一个";页面未找到";错误代码:

<Files "/configurator.php">
RewriteRule ^(.*)$ configurator.php?page=$1 [QSA]
RewriteRule ^([^.]+)$ $1.php [NC,L]
</Files>

唯一能与配置器一起工作的是编写";localhost/mypage/configurator";或";localhost/mypage/configurator?page=测试。

为什么它不按预期工作?

这样做:

Options -MultiViews
RewriteEngine On
# handle configurator 
RewriteRule ^(configurator)/(.+) $1.php?url=$2 [L,QSA,NC]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/mypage/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
# front controller rule
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

最新更新