atDev
April 19, 2010, 8:20pm
1
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
dklynn
April 19, 2010, 10:18pm
2
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
atDev
April 20, 2010, 1:50am
3
Using:
Options -MultiViews
Seems to make the original rule work?
dklynn
April 20, 2010, 4:47am
4
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
atDev
April 20, 2010, 1:01pm
5
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.
dklynn
April 21, 2010, 7:51am
6
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