I am trying to send every request www.example.com/user/
to www.example.com/user.php?id=0
using this
RewriteRule ^user/$ user.php?id=0
Basically, if someone accesses www.example.com/user/
without a user ID, the site will default to id = 0
.
However, when I type www.example.com/user/
, Apache seems to just serve the user.php file, completely ignoring the RewriteRule. Any idea on why this is happening?
Thanks.
I should mention that this only happens if I use the same word in the URL as the php file name. For example, if I used
RewriteRule ^yes/$ user.php?id=0
Going to www.example.com/yes/
apply the RewriteRule just fine. Therefore, it seems that Apache is looking for a file with that name and ignores the RewriteRule. And no, adding the [L] flag didn't help.
Here is my .htaccess:
RewriteEngine On RewriteRule ^user/$ user.php?id=0 RewriteRule ^user/([0-9]+)$ user.php?id=$1
user1066994
source share