Forum Moderators: phranque

Message Too Old, No Replies

Cannot compile RewriteRule

         

Furutsuzeru

4:41 pm on Aug 5, 2008 (gmt 0)

10+ Year Member



I am trying to creatr RewriteRule's since I dislike the default querystrings. I am using the following RewriteCode, though it returns a 500 error and it says in my error logs:


[Tue Aug 5 11:40:12 2008] [alert] [client 68.173.196.176] /home/pokeuniv/public_html/example.net/stuff/audentio/.htaccess: RewriteRule: cannot compile regular expression '^search/([A-Za-z-0-9-]+)$'\n

My RewriteRule is as follow:


#Searching
RewriteRule ^search$ search/ [R]
RewriteRule ^search/$ search.php
RewriteRule ^search/([A-Za-z-0-9-]+)$ search/$1/ [R]
RewriteRule ^search/([A-Za-z-0-9-]+)/$ search.php?do=$1

If anybody could help me out with this, I'd appreciate it.

[edited by: jdMorgan at 9:36 pm (utc) on Aug. 5, 2008]
[edit reason] example.net [/edit]

Furutsuzeru

9:10 pm on Aug 5, 2008 (gmt 0)

10+ Year Member



Hi again. I was wondering if anybody could assist me on this, or hint at some sort of solution?

jdMorgan

9:41 pm on Aug 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, this is not Instant Messaging...

You have an un-needed (and illegal) hyphen between "z" and "0" in the grouped character subpatterns of your last two rules, and the "9" is then followed by another un-escaped (and therefore potentially-illegal) hyphen.

I also note that you are missing the [L] flag from all rules, and that you're using a 302-Found redirect (by default).

I strongly suggest that you use [L] on all rules unless the output of a rule needs to be further processed by a subsequent rule, and that you use [R=301] and a full canonical URL to generate permanent redirects. Example:


RewriteRule ^search/([b][A-Za-z0-9\-][/b]+)$ [b]http://www.example.com/[/b]search/$1/ [[b]R=301,L[/b]]

Jim

Furutsuzeru

11:29 pm on Aug 5, 2008 (gmt 0)

10+ Year Member



Wow, that really did it. Thank you VERY much, jdMorgan. I'll note down my mistake and remember it.