Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 currently have PHP scripts that work properly, being called like this:


I'm having trouble getting .htaccess to rewrite properly. I'm trying to achieve this:


So far, I can get it to redirect /user to /user.php, but the /paul is lost; breaking my script.

My current .htaccess looks like this:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /([^.\ ]+\.)+php(\?[^\ ]*)?\ HTTP
RewriteRule ^(.+)\.php$$1 [R=301,L]
RewriteRule ^([^/]+/)*index/?$$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$$1 [R=301,L]
RewriteCond $1 !^([^.]+\.)+([a-z0-9]+)$ [NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*[^/])$ /$1.php [L]

Please help. Thanks! Paul

share|improve this question
RewriteRule ^(.+)\.php$$1 [R=301,L]

Should look like:

RewriteRule ^(.+)\.php/(.+)$$1/$2 [R=301,L]

The items in parenthesis can be referenced in the target as $N for each regex in parenthesis you have.

share|improve this answer
still doesn't work, sorry – Paul Jun 8 '11 at 0:33
Do you mean you want user input to be presented to httpd as – James Jun 8 '11 at 1:29
yes, that's what needs to happen – Paul Jun 8 '11 at 5:22
any other ideas? – Paul Jun 8 '11 at 20:57
What about this? RewriteRule ^(.+)/(.+)$$1.php/$2 [L] – James Jun 9 '11 at 22:15

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.