Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

403 redirect doesn't work

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!

like image 904
tsds Avatar asked Jan 19 '23 17:01

tsds


1 Answers

Try this instead:

RewriteRule ^forbid/(.*)$ - [F]

Source: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_f

like image 104
onteria_ Avatar answered Jan 23 '23 10:01

onteria_