403 重定向不起作用
如何强制 apache 重定向到 403 错误?
我已经尝试过:
RewriteRule ^forbid/(.*)$ / [R=403,L]
这会导致整个网站出现 500 服务器错误
RewriteRule ^forbid/(.*)$ - [R=403,L]
,而
RewriteRule ^forbid/(.*)$ [R=403,L]
这些根本不起作用
我有以下 .htaccess 文件:
RewriteEngine on
RewriteRule ^(config|backup)(.*)$ - [F] [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin/(.*)$ /admin/index.php?%{QUERY_STRING} [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !util
RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [L,QSA]
请帮助我!
How to force apache to redirect to a 403 error?
I've tried:
RewriteRule ^forbid/(.*)$ / [R=403,L]
this caused 500 server error on the whole site
RewriteRule ^forbid/(.*)$ - [R=403,L]
and
RewriteRule ^forbid/(.*)$ [R=403,L]
these simply don't work
I have the following .htaccess file:
RewriteEngine on
RewriteRule ^(config|backup)(.*)$ - [F] [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin/(.*)$ /admin/index.php?%{QUERY_STRING} [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !util
RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [L,QSA]
Please, help me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
来源:http://httpd.apache.org/docs /current/rewrite/flags.html#flag_f
Try this instead:
Source: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_f
除非您定义了我们在您的规则中看不到的
RewriteBase
,否则我认为您不希望在“禁止”您的表达式之前使用^
,因为从技术上讲它会以“/”开头Unless you have a
RewriteBase
defined that we don't see in your rules, I think you don't want the^
before 'forbid' your expression, since it would technically start with '/'