0
votes

I'm struggling to get a simple URL rewrite in my htaccess file to work. It looks like this:

RewriteRule    ^getbars/([A-Za-z\d,]+)?$    getbars.php?guid=$1    [NC,L]

The idea is to redirect URLs such as /getbars/519f1dec603f9 to /getbars.php?guid=519f1dec603f9

For some reason, however, the guid parameter is empty when I try to get it in getbars.php

However, if I change it to

RewriteRule    ^bars/([A-Za-z\d,]+)?$    getbars.php?guid=$1    [NC,L]

and load /bars/519f1dec603f9 in my browser instead, it seems to work OK.

What am I doing wrong?

1
Do you have any other rewriterules? if you have another one above the first rule you listed, it will match that one and never get to the one you wanted. - melwil
Nope. I get the same result even when I remove all other rules - rodskagg
@andlin It could be cached by browser. Have you tried to clear cache, or try in another? - vmeln
Actually, when testing things like this, I can recommend using the incognito mode in chrome. If you want to clear caches, you can just close the tab and open a new one. - melwil

1 Answers

1
votes

Because the content negociation is enabled on your server (combined to PATH_INFO feature here)? If this is the case, the content negociation automatically "rewrites" getbars/* to getbars.php, before reading rewriting rules.

=> Can you try to add Options -MultiViews in your .htaccess?