Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule for dictionary

a-z and #

         

twist

5:14 am on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteRule ^[a-z]+)?$ /dictionary.php?letter=$1 [L]

What syntax would I use to get a-z and the # symbol?

Is there a way to limit it to the only one letter?

It only allows a, b, c, d and so on, no asdf.

jdMorgan

6:02 am on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



twist,

Take a look at the regular-expressions tutorial cited in our charter [webmasterworld.com] for help with regular expressions.

Your current pattern has a syntax error, a missing "(".

I believe you want:

^([a-z#])$ for a single letter or "#", or
^([a-z#])?$ for a single letter, "#", or blank.

Jim

twist

5:43 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks a lot jim, I read through the charter and am curious if there is a way to make the following shorter.

I want to create a listing for all the months in a year like so,

RewriteRule ^jan$ /events.php?m=jan [L]
RewriteRule ^feb$ /events.php?m=feb [L]
RewriteRule ^mar$ /events.php?m=mar [L]

and so on...

So far the only way I can see of making this shorter is something like this,

RewriteRule ^(jan圩eb妃ar地pr妃ay夸un夸ul地ug存ep她ct好ov圬ec)$ /events.php?m=$1 [L]

Would this be the best way?

jdMorgan

2:52 am on Jan 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's how I'd do it. :)

Jim