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

Here is my rule:

RewriteRule ^user/(\d+)$ rewrite.php?id=$1

This redirects, but $_GET['id'] is not set. If I change the above rule to:

RewriteRule ^anything/(\d+)$ rewrite.php?id=$1

It works. Why does one work but not the other?

Here is more information:

  • There is no directory named user
  • The only other .htaccess file in the hierarchy is blank.
  • anything can be replaced by anything other than user.

Update: I checked the rewritelog and it's empty.

share|improve this question

I finally found the cause of the problem... Apparently (and this is documented nowhere that I could find) if you have a file (in this case, PHP) with the same name as the first virtual directory the rewrite rule doesn't work. (Redirect loops, missing parameters, etc.)

For example, the following rule:

#RewriteRule ^user/(\d+)$ user.php?id=$1 [L]

Will malfunction if there is a file named user.php in the same directory as the PHP file.

share|improve this answer
You probably have activated mod_speling ( in your Apache httpd configuration which causes this effect. – joschi May 9 '10 at 5:59
Nope. A quick check shows that mod_speling is disabled. – Nathan Osman May 9 '10 at 6:25
Disable MultiViews. – Mo. May 9 '10 at 11:40

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.