Reputation: 2387
I'm trying to redirect from r.php?username={variable} to r/{variable}/ (last slash optional) with my htaccess.
Username:
So, $username
is correct if preg_match('/^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$/',$username)
So, now, what's wrong with my htaccess?
RewriteRule ^r/^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*$/?$ r.php?username=$1
Upvotes: 1
Views: 60
Reputation: 18671
Try with this .htaccess:
RewriteRule ^r/([A-Z](?:[A-Z0-9_]*[A-Z0-9]+)?)/?$ r.php?username=$1 [NC,L]
Upvotes: 1