Page 1 of 1

simple question regarding regex in an .htaccess file

Posted: Sun Oct 12, 2008 10:19 pm
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!!!

Re: simple question regarding regex in an .htaccess file

Posted: Sun Oct 12, 2008 10:45 pm
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...