Forum Moderators: phranque

Message Too Old, No Replies

Mod-rewrite - characters and letters in a string "e.g [a-zA-Z ] string

         

kadhumia flo

11:31 am on Feb 17, 2008 (gmt 0)

10+ Year Member



Hello

I am using mod_rewrite for my site and will be using dashes in the page names instead of spaces. So the URLS should look like this

http://www.example.com/What-to-do-in-a-fire-45.php

I want specifically to only allow the dashes and the letters in one htaccess string (I have my reasons for not using (.*). I am thinking something like [a-zA-Z-].

Is there a way?

Thanks in advance

phranque

2:16 pm on Feb 17, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



[a-zA-Z-] will match a single character that is either alphabetic or a dash.
if you are using this regexp in a mod_rewrite directive you can use [a-z-] and the [NC] flag which means "no case" and makes the pattern case insensitive.

what about the numerics?
maybe you want a pattern more like:
([a-zA-Z]+-)+[0-9]+\.php$

which means:
at least one alphabetic and a dash, one or more times, followed by one or more numerics, ending in ".php".