【发布时间】:2018-02-04 03:55:25
【问题描述】:
在我的 .htaccess 文件中,我有将 http://www.myownwebsite.com/about.php 等 URL 重写为 http://www.myownwebsite.com/about/ 的设置。
我还有自定义错误 403 和 404 页面的设置。
我遇到的问题是,当我测试直接访问文件夹(例如 http://www.myownwebsite.com/css/)时,我看到的不是自定义 403 页面,而是自定义 404 页面。我猜是因为url重写的设置覆盖了自定义403页面的设置。
这是我的 .htaccess 文件中的相关代码:
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
我做错了什么?
【问题讨论】:
标签: .htaccess url-rewriting http-status-code-404 http-status-code-403