Having trouble searching for a ‘.’ using htaccess.

Posted by ThisLanham on Server Fault See other posts from Server Fault or by ThisLanham
Published on 2010-04-02T22:11:26Z Indexed on 2010/04/02 22:13 UTC
Read the original article Hit count: 188

I'm setting up a website that (ideally) would allow users to access other users' homepages with a url in the format "www.mysite.com/ThisLanham" where 'ThisLanham' is the username. The username begins with a letter and can consists of any alphanumeric character along with an underscore, hyphen, or period.

So far, the redirection has worked perfectly when I ignore usage of the period character. The following code handles that request:

RewriteRule ^([a-zA-Z][0-9a-zA-Z-_]*)/?$ Page/?un=$1 [NC,L]

However, I've tried a number of ways it check for the period as well, but all have resulted in a 500 Internal Server Error. Here are some my attempts:

RewriteRule ^([a-zA-Z][0-9a-zA-Z-\_\\.]\*)/?$ Page/?un=$1 [NC,L]
RewriteRule ^([0-9a-zA-Z-\_\\.]\*)/?$ Page/?un=$1 [NC,L]
RewriteRule ^([a-zA-Z].\*)/?$ Page/?un=$1 [NC,L]
RewriteRule ^(.\*)/?$ Page/?un=$1 [NC,L]

also tried...

RewriteCond $1 != index.php
RewriteRule ^([a-z][0-9a-z-_.]*)/?$ Page/?un=$1 [NC,L]

My backup plan is to no longer allow users to include periods in their usernames, but I'd much rather find a solution. Any ideas?

© Server Fault or respective owner

Related posts about .htaccess

Related posts about htaccess