【发布时间】:2021-10-10 00:50:52
【问题描述】:
我正在使用 xampp 测试一些 php 代码。
在主项目目录中,我有以下 .htaccess 文件:
RewriteEngine on
#Index
RewriteCond %{REQUEST_FILENAME} ^/$
RewriteRule request_handler.php [L]
#php files
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} ^.*(\.php)$
RewriteRule . request_handler.php [L]
#Blocked files. PHP blocked files should be specified in request_handler.php
<Files "setup.json">
Order Allow,Deny
Deny from all
</Files>
<Files "testimonials.json">
Order Allow,Deny
Deny from all
</Files>
#CACHE CONTROLL FOR STATIC RESOURSES
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
无论如何,我在所有请求中都遇到了意外的 403 禁止。但是,如果我删除 .htaccess 文件的第一行,我将不再出现这种意外行为。
有谁知道是什么导致了这个错误?
更新
我创建了一个新的 .htaccess 文件,它只包含一行:RewriteEngine On,但我仍然收到错误消息。 (如果我删除该行,我将停止收到错误)。该行的唯一存在会导致错误。
【问题讨论】:
标签: php apache .htaccess xampp http-status-code-403