1

I have a directory named 'appfolder'. I have used the following .htaccess for using for every unknown file to use index.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

If I open domain.com/appfolder it gives me the default apache forbidden page instead of using index.php

How can I also set to use index.php for directories in .htaccess

7
  • For that you first have to find out why you get that "forbidden" error. Please take a look into your http servers error log file. You should find some more specific reason there. Commented Apr 13, 2016 at 17:32
  • This is the default in apache for not to list directorys and give a forbidden error. I am asking how to use index.php for existing directories. Commented Apr 13, 2016 at 17:37
  • That is not the question at hand, sorry. If your rewriting rules work (I assume you tested that...), then you do not want to use the "builtin" directory index feature at all. What I meant with my questions is: there are different reasons that can lead to the error your describe. Without knowing which of the different reasons is responsible it is much harder to solve the issue. So why don't you simply take a look into that log file? Commented Apr 13, 2016 at 17:41
  • answer provided by @anubhava is exactly what I wanted and thank you arkascha for your precaution comments Commented Apr 13, 2016 at 17:43
  • 1
    OK, great that you solved the issue by that "blind shot". But do yourself a favor and find out about that http servers error log file. You will need it again and again. You cannot operate an http server without that. Commented Apr 13, 2016 at 17:44

1 Answer 1

1

How can I also set to use index.php for directories in .htaccess

Remove this condition:

RewriteCond %{REQUEST_FILENAME} !-d

Full .htaccess:

RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.