Mobile app version of vmapp.org
Login or Join
Holmes151

: 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

@Holmes151

Posted in: #403Forbidden #Htaccess

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Holmes151

1 Comments

Sorted by latest first Latest Oldest Best

 

@Deb1703797

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme