Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a website that is the root folder It has a .htacces with below code :

RewriteEngine on
RewriteRule ^(.*)/$ $1.php

When I open I got 404 not found error but when I open without the trailing / the url will open without any problem.

I need htaccess code too set in the root directory to open php file like login.php as /login/ or login without / and with /


share|improve this question

Try ^([^/]+)/?$ and see if it works as expected.

share|improve this answer
After try this code RewriteEngine on RewriteRule ^([^/]+)/?$ $1.php i got 500 error – Mahmood Aug 19 '12 at 16:21

Your Answer


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.