simple question regarding regex in an .htaccess file

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
scheinarts
Forum Commoner
Posts: 52
Joined: Wed Jul 25, 2007 2:37 am

simple question regarding regex in an .htaccess file

Post by scheinarts »

Hi,

I have this .htaccess file using mod_rewrite and I need to be able to write the correct regex... Here is my htaccess file...

Code: Select all

 
<IfModule mod_rewrite.c>
 
RewriteEngine On
RewriteBase /
 
RewriteRule ^([a-z]+)/$ index.php?user=$1
RewriteRule ^([a-z]+)$ index.php?user=$1
 
</IfModule>
 
Right now it only accepts strings from a-z (small caps only)...

So my question is how can I make it accept numbers, dash or underscore and letters in Big caps.... Yes, I know next to zero about writing regular expressions...

The value sent is a user defined username, so it could be any combination of the ones i described above. The mod_rewrite works great so I just need help with getting the correct regex.


Many Thanks!!!
User avatar
omika
Forum Newbie
Posts: 19
Joined: Sun Oct 12, 2008 2:00 pm
Location: New Zealand

Re: simple question regarding regex in an .htaccess file

Post by omika »

I'm not that great with regex either but there is a great website that has a library of combination's.
http://regexlib.com/

maybe

Code: Select all

RewriteRule ^([A-Za-z0-9\-\_]+)/$ index.php?user=$1
will work...
Post Reply