Forum Moderators: phranque
I need to update my .htaccess file. Currently I have this ([0-9A-Za-z]+) in one of my lines for looking for a filename (ex. index.html) but some of my files have -'s in them (ex product-index.html). I was curious what I need to add to that snippet to allow -'s to be included. I guess it would be considered a special character.
Thanks :)
Wes
Alternately, use a negative match. Instead of looking for characters which are part of the field, look for the character that denotes the end of the field. Let's say your URL is
/articles/jun-2005-summer/page2
You could use articles/([A-Za-z-0-9\-]+)/(.*) or you could use articles/([^/]+)/(.*). The first subexpression of the latter pattern would match any character between the first and second slashes.
If you do decide to stick with [A-Za-z0-9], then look into using the [NC] flag, which will reduce the needed pattern to [a-z0-9].
Jim