我的自定义配置文件中有以下代码。
<Directory "/www">
Options Indexes FollowSymLinks
AllowOverride All
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
ErrorDocument 403 "Please disable proxies to view content."
RewriteEngine On
RewriteRule ^(.*\.php)s$ $1 [H=application/x-httpd-php-source]
RewriteRule ^faq/(\w+)/(\d+)/?$ faq.php?code=$1&num=$2 [NC]
</Directory>
现在,当我浏览到类似/index.phps
or的网页时/some/other/dir/and/file.phps
,我在浏览器中收到 404 错误,并且在 apache 的错误日志中记录了以下内容:
[<date>] [:error] [pid 15154:tid 3024079728] [client <IP>] script 'redirect:/request/get_req.php' not found or unable to stat
[<date>] [:error] [pid 15152:tid 2914974576] [client <IP>] script 'redirect:/index.php' not found or unable to stat
什么可能导致此问题?另外,请注意第二个RewriteRule
forfaq/..
运行良好。我在每个目录的基础文件中还有一些重写规则,htaccess
并且所有这些规则都可以正常工作。
我使用的服务器版本是Apache/2.4.9 (Unix)。
在听取了covener和anubhava的建议后;我将conf
文件更新为:
<VirtualHost *:80>
DocumentRoot "/www"
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
LogLevel warn
</VirtualHost>
<Directory "/www">
Options Indexes FollowSymLinks
AllowOverride All
RewriteEngine On
# RewriteRule ^(.*\.php)s$ %{DOCUMENT_ROOT}/$1 [H=application/x-httpd-php-source]
# RewriteRule ^/?(.*\.php)s$ %{DOCUMENT_ROOT}/$1 [H=application/x-httpd-php-source]
# RewriteRule ^(.*\.php)s$ $1 [H=application/x-httpd-php-source]
RewriteRule ^(.*\.php)s$ %{DOCUMENT_ROOT}/$1 [H=application/x-httpd-php-source]
RewriteRule ^faq/(\w+)/(\d+)/?$ faq.php?code=$1&num=$2 [NC]
</Directory>
但是 php 源的处理程序仍在记录相同的错误:
[<date>] [:error] [pid 17586:tid 2956938096] [client <IP>] script 'redirect:/index.php' not found or unable to stat