PDA

View Full Version : Mod_rewrite problems (yet again)


rich w
October 17th, 2007, 00:13
Greetings all!

I'm having a few problems with mod_rewrite at the moment. Surprise! :lol:

Basically, i've got the following set of rules running on Apache 2 on my development server. However, when I upload to the Apache 1.x live environment, I get this error:
/home/studento/public_html/.htaccess: RewriteRule: cannot compile regular expression '^cache/users/rand([a-zA-Z0-9-.]+)_([0-9]+)_([0-9]+).jpg$'\n


RewriteEngine on

RewriteRule ^cache/users/rand([a-zA-Z0-9-.]+)_([0-9]+)_([0-9]+).jpg$ cache/users/$2_$3.jpg [NC]

RewriteRule ^friends/$ friends/index.php [NC]
RewriteRule ^friends/([0-9]+)/$ friends/view.php?id=$1 [NC]
RewriteRule ^friends/([0-9]+)$ friends/view.php?id=$1 [NC]

RewriteRule ^news/([a-zA-Z0-9-]+)/$ news/index.php?z=$1 [NC]
RewriteRule ^news/([a-zA-Z0-9-]+)/([0-9]+)/$ news/index.php?z=$1&id=$2 [NC]

RewriteRule ^zones/([a-zA-Z0-9-]+)/$ zones/index.php?z=$1 [NC]
RewriteRule ^zones/([a-zA-Z0-9-]+)/things/$ things/index.php?z=$1 [NC]
RewriteRule ^zones/([a-zA-Z0-9-]+)/things/([a-zA-Z0-9-_]+)/$ things/thing.php?z=$1&t=$2 [NC]

RewriteRule ^zones/([a-zA-Z0-9-]+)/things/([a-zA-Z0-9-_]+)/discussion/$ things/discussion_newtopic.php?z=$1&t=$2 [NC]
RewriteRule ^zones/([a-zA-Z0-9-]+)/things/([a-zA-Z0-9-_]+)/discussion/([a-zA-Z0-9-]+)/$ things/discussion.php?z=$1&t=$2&top=$3 [NC]


Any thoughts, solutions etc would be appreciated :)

inimino
October 17th, 2007, 00:28
'^cache/users/rand([a-zA-Z0-9-.]+)_([0-9]+)_([0-9]+).jpg$'\n

[a-zA-Z0-9] I understand, but what does [a-zA-Z0-9-.] mean? You can't string ranges together like that, perhaps [a-zA-Z0-9.] was intended?

rich w
October 17th, 2007, 09:29
Sorted :D

To be honest, the -. shouldn't have been there! I don't know why it was! I took that out, and that rule worked fine.

The rest of the rules, it was down to the [a-zA-Z0-9-_] that was causing the problem. I swopped it for [_a-zA-Z0-9-], and all is fine and dandy :)

Cheers once again!