首页 > 解决方案 > htaccess 修改导致 ACCESS FORBIDDEN, ERROR 403 即使删除 htaccess 文件也无法纠正

问题描述

玩弄“友好的 URL”并创建了一个 htaccess 文件:

RewriteEngine On
RewriteRule    ^modules/posts/questions_all.php/?$  modules/posts/questions_all.php    [NC,L] 

目的是能够将 http://localhost/modules/posts/questions_all.php/1234(带有友好的 URL 后缀 /1234)重定向到普通页面 http://localhost/modules/posts/questions_all.php

然后我尝试按照另一篇网络帖子中的建议添加其他行(但不了解它们的实际作用),使其成为:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule    ^modules/posts/questions_all.php/?$    modules/posts/questions_all.php    [NC,L] 

在此之后,当我尝试通过 HREF 链接访问正常页面时,似乎开始收到“禁止访问,错误 403”消息。HREF 链接没有改变,但现在地址栏中的 URL 显示为:

http://localhost/C:/xampp/htdocs/Data/anyCompany/modules/posts/questions_all.php

而不是:

http://localhost/modules/posts/questions_all.php

现在,我似乎无法再通过此链接使系统恢复正常运行。即使删除 htaccess 文件也没有更正它。RewriteCond 命令是否更改了我需要以某种方式撤消的其他设置?

标签: apache.htaccess

解决方案


不知道它是如何进入上述错误状态的,但是清除缓存解决了这个问题。没想到 .htaccess 文件会被缓存...


推荐阅读