Rewrite rule for 403
Rewrite rule for 403 -
Solution :
Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, 403-forbidden, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :I have an .htaccess file:
In this file it redirects to index.php in case a file or directory is not found.
My code is as below:
<IfModule mod_rewrite.c>
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Everything is working fine with this code. Now when I get Forbidden error(403), I would like it to be redirect to index.php.
Do you have an idea how to write an .htaccess file for this purpose?
You want to use the ErrorDocument rule. Using your example, it might look something like this:
<IfModule mod_rewrite.c>
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
ErrorDocument 403 index.php
Comments
Post a Comment