I currently have a .htaccess file set up with this rule:
RewriteRule ^([a-zA-Z0-9_-]+)$ user\.php?user=$1 [L]
which works as expected:
mysite.com/joe becomes mysite.com/user.php?user=joe
How could I change the regex to include periods in a possible username?
For example I would like
mysite.com/joe.bloggs to go to mysite.com/user=joe.bloggs
Currently this brings up a 404 missing page error.
I have tried ^([a-zA-Z0-9\._-]+)$ user\.php?user=$1 [L]
But this produces an internal error 500 (I think this is due to an infinite loop: user.php is designed to redirect to the homepage if no user is specified.)
I’m pretty new to all of this (regex especially). Thanks for any help!
First check if the requested URLs is not a file or folder. This will prevent the redirect loop for URLs like
/user.php