Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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

When I open http://mysite.com/login/ I got 404 not found error but when I open http://mysite.com/login 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

1 Answer 1

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.