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 this code somewhere in my .htaccess file:

RewriteRule /user/([a-zA-Z0-9]+) /iduser.php?username=$1

It should make /user/oliolio request iduser.php?username=oliolio, however it doesn't work. :(

Do you know why?

share|improve this question

migrated from Jun 1 '11 at 17:45

This question came from our site for professional and enthusiast programmers.

Can you confirm that rewrite rules are working over all, too? – Gavin C Jun 2 '11 at 11:32
up vote 2 down vote accepted
RewriteRule ^(.*)/user/([a-zA-Z0-9]+)$ /iduser.php?username=$2 [L]

Or if its just then

 RewriteRule ^user/([a-zA-Z0-9]+)$ /iduser.php?username=$1 [L]

Make sure RewriteEngine On is set

share|improve this answer
Appreciate that you kept the asker's character/number restriction in the regex, but might want to simplify to using [a-z0-9] and adding the "nocase / NC" directive – Gavin C Jun 2 '11 at 11:30

Have your rule like this:

RewriteRule ^user/(.*)/?$ /iduser.php?username=$1 [QSA,NC,L]

Apache strips out leading slash / that's why your rule is not working.

share|improve this answer

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.