Forum Moderators: phranque

Message Too Old, No Replies

intermittent rewrites

apache mod_rewrite rules sometimes working and others not

         

fastback72

8:36 am on May 27, 2006 (gmt 0)



I am having an issue with apache mod_rewrite where rules sometimes work, sometimes they do not. A restart fixes it but not for long. I have logged the rewrites. Sometimes the match is made and other times it is not even though the requested URL is exactly the same.

Does anyone else have experience with this occuring? Is it memory, load related? It seems that it must be because, as I said, a restart fixes it.

I have many rules. These are the ones that play up more often than the others:
1) RewriteRule ^\/vehicles\/([^\/]*)\/([^\/]*)\/([0-9]+)\/?$ /group_vehicle_view.php?make=$1&model=$2&vehicle=$3 [L,NC]
2) RewriteRule \/news\/([0-9]+)\/?$ /group_news.php?id=$1 [L,NC]
3) RewriteRule \/artists\/([A-Z_]*)\/?([0-9]*)?\/? \/artist.php?artist=$1&offset=$2 [L,NC]

- Brad

jdMorgan

2:50 pm on May 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This certainly isn't a common problem...

Nothing in your sample rules jumps out as being "wrong," and the only comments I can make are that "/" does not need to be escaped in mod_rewrite, and that the last sample rule is too ambiguous for my tastes, since it's not start-anchored and the second or third (artist or offset) parameter (or both) may be omitted and still match. But as long as you expect that, I suppose it's OK.

Also ([0-9]*)? is a bit redundant.

Clearing up just the character-escaping and redundant pattern issues, I'd write that last rule like this:


RewriteRule /artists/([A-Z_]*)/?([0-9]*)/? /artist.php?artist=$1&offset=$2 [L,NC]

Jim