Odd mod_rewrite issue

Hi everyone,

I’m coming across this weird RewriteRule issue and don’t know how to remedy it.

Although mod_rewrite works like I want it to on other directories in my site, when I try to write the simple rule below, the GET variable is not stored.

RewriteRule ^account/([a-z]+)$ account.php?mod=$1 [NC]

After messing around with the code a bit, I realized that what is seeming to cause the rule not to function correctly are the 2 “account” strings. It seems that whenever those two are the same, the rule does not work, but, if they are different, it does.

Does anyone know how I can fix this? Any help is appreciated! Thanks!

LL,

Aw, shucks! :blush:

ScallioXTX gets all the credit for this one, though, as I didn’t even consider that this was a MultiViews problem until he mentioned it. :tup:

Regards,

DK

The Options -MultiViews worked like a charm! Thanks to both DK and Scallio for your help!

LL,

Yes, Options -MultiViews is something that I consider important as it would force Apache to fetch the file rather than the directory for accounts. As a part of the Apache core, that would take precedence over your mod_rewrite.

Then, the differrence between “the two account strings” is that you are redirecting ^{start} followed by ‘account’ followed by / followed by {one or more lowercase letters} followed by NOTHING. That’s being redirected to account.php with the key mod being assigned a value of {the one or more lowercase letters}. Please note, though, that by creating a new query string, it’s killing any pre-existing query string, too.

If that’s not clear enough, please show your TEST URIs.

Regards,

DK

What DK meant is you should replace [NC] (which is not needed for your .htaccess) with [L]

And, it sounds like you’re having trouble with MultiViews. Try adding Options -MultiViews to the .htaccess:


Options -MultiViews

RewriteEngine On
RewriteRule ^account/([a-z]+)$ account.php?mod=$1 [L]

This is the only rule in the file, so I’m not sure that that is the case…

What I meant by the two strings is that when they are the same (like above), the rule does not work. However, when they are different, like so, the rule functions correctly.

RewriteRule ^account/([a-z]+)$ accounts.php?mod=$1 [NC]

Thanks for your reply!

LL,

The “two account settings” would make no difference (they are not the same).

No Case? In preference to the Last Flag? I’ll bet the preceding RewriteRule was not terminated by a Last flag (either) so this RewriteRule is being ANDed with it, thus, it’ll never match.

Regards,

DK