Rewrite rule fails on certain versions of apache

Is there a reason this rewrite rule works on some versions of apache but not others?

RewriteRule ^classified/([0-9]+)\.html$ my_classifieds.php?id=$1 [L,NC]

If I change it to:
RewriteRule ^classifieds/([0-9]+)\.html$ my_classifieds.php?id=$1 [L,NC]

It works fine.

The same goes for something like this:
RewriteRule ^page/([0-9]+)\.html$ my_page.php?id=$1 [L,NC]

It started working after changing the word “page” to “pages”.

It is as if “classified” and “page” and perhaps other words are reserved by apache and do not work?

It does not work in Apache is 1.3.xx

AD,

Yes, Apache 1.x requires the regex to match the / between the domain and path/script after the start anchor, i.e.,

RewriteRule ^[COLOR="Red"]/[/COLOR]classified/([0-9]+)\\.html$ my_classifieds.php?id=$1 [L,NC]

If you want to have your code work on both Apache 1.x and Apache 2.x, use

RewriteRule ^/?classified/([0-9]+)\\.html$ my_classifieds.php?id=$1 [L,NC]

There is no reason for an embedded “s” to cause any difference, i.e., inexplicable (restart Apache - it may be a problem within the application).

Regards,

DK

Using:
Options -MultiViews

Seems to make the original rule work?

AD,

That should have NOTHING to do with this problem (although, IMHO, MultiViews is a terrible thing to use so your -MultiViews is a good thing to do).

Regards,

DK

Right, I understand but I am simply letting you know what worked.

If I comment that line out, it doesn’t work. Uncomment, it works.

AD,

Oh, no! Then you must have a script named classifieds.{whatever} in the DocumentRoot which is receiving the MultiView redirection. That’s NOT a good thing (i.e., leave MultiViews OFF (-)).

Regards,

DK