【发布时间】:2014-07-14 17:21:06
【问题描述】:
我的自定义配置文件中有以下代码。
<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 或 /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
什么可能导致这个问题?另外,请注意faq/.. 的第二个RewriteRule 工作正常。我在每个目录的 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
【问题讨论】:
标签: apache .htaccess mod-rewrite redirect apache2.4