I'm attempting to send every request to www.example.com/user/ to www.example.com/user.php?id=0 by using this

RewriteRule ^user/$ user.php?id=0

Essentially, if a person is being able to access www.example.com/user/ without any user id, the website will default to id = 0.

However, after i type www.example.com/user/ Apache appears to merely serve the consumer.perl file, completely disregarding the RewriteRule. Any idea on why this really is happening?

Thanks.

I ought to point out that this only happens basically make use of the same word within the URL because the php file's title. For instance, basically would use

RewriteRule ^yes/$ user.php?id=0

Likely to www.example.com/yes/ would apply the RewriteRule all right. Therefore it appears that Apache searches for personal files with this title and ignores the RewriteRule. With no, adding a [L] flag didn't help.

Here's my .htaccess:

RewriteEngine On
RewriteRule ^user/$ user.php?id=0
RewriteRule ^user/([0-9]+)$ user.php?id=$1 

do this:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^user/$ user.php?id=0 [L,NC,QSA]
RewriteRule ^user/([0-9]+)/?$ user.php?id=$1 [L,NC,QSA]

The [L] flag causes mod_rewrite to prevent processing the rule set. In many contexts, which means that when the rule matches, no further rules is going to be processed. This matches the final command in Perl, or even the break command in C. Make use of this flag to point the current rule ought to be applied immediately without thinking about further rules.

from: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_l

I believe this is exactly what you would like.

RewriteEngine On
RewriteRule ^user/$ user.php?id=0 [L]

I believe your rewrite rules have been in the incorrect order, and you are not while using [L] flag to inform apache to not run anymore rules whenever a rule's been matched up. Also you could utilize the + operator rather than * to complement a minumum of one digit inside your second rule:

RewriteRule ^user/$ user.php?id=0 [L]
RewriteRule ^user/([0-9]+)$ user.php?id=$1 [L]