I have a simple rewrite rule, which works fine as expected:
RewriteRule ^user/(\w+)/?$ user.php?id=$1
I have a php file with:
<?php echo $_GET['id']; ?>
That works fine with the following URL, and id gets passed no problem:
http://localhost/user?id=JoeUser
I know that mod_rewrite is working because this url also sends me to user.php:
But JoeUser is never actually passed to $1. I have never seen this behaviour before. Is it a bug in OS X, or am I missing something?
Is it a bug in OS X?
No this is not a bug. This is effect of MultiViews
option which is enabled by default in your Apache config. Option MultiViews
is used by Apache's content negotiation module
that runs before mod_rewrite
and makes Apache server match extensions of files. So /file
can be in URL but it will serve /file.php
.
To turn it off use:
Options -MultiViews
RewriteEngine On
RewriteRule ^user/(\w+)/?$ user.php?id=$1 [L,QSA,NC]