0

I'm using this code to "remove" .php extensions:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] 

So I can go to mysite.com/about instead of mysite.com/about.php.

It works fine but when I have a directory like:

mysite.com/admin (inside there I have a index.php) it throws a Forbidden 403 error. How can I fix this?

Btw, if I go to mysite.com/admin/index it works.

1 Answer 1

2

I think this is caused because you don't exclude directories. Try something like this:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.