Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question
add comment

migrated from superuser.com Apr 11 '13 at 10:58

This question came from our site for computer enthusiasts and power users.

1 Answer

up vote 1 down vote accepted

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
share|improve this answer
    
Thanks for your answer you great bro... your answer was not exact but found the way...thanks again –  Jitesh Tukadiya Apr 12 '13 at 5:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.