![Holmes151](https://vmapp.org/images/player/000default.jpg)
: Rewrite rule for 403 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
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?/ [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?
More posts by @Holmes151
1 Comments
Sorted by latest first Latest Oldest Best
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?/ [L]
</IfModule>
ErrorDocument 403 index.php
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.