Reputation: 75
I used this code
RewriteRule ^/([^\.]+)$ profile.php?u=$1 [QSA,L]
It worked fine for me but when i tried to visit a file in next folder like http://example.com/blog
it automatically shows the profile.php code. Is there any method to skip folders during that htaccess?
PS: In username Alphanumeric characters, hyphen(-), dot(.) and underscore(_) are allowed.
Upvotes: 1
Views: 64
Reputation: 785376
In username Alphanumeric characters, hyphen(-), dot(.) and underscore(_) are allowed.
Restrict your pattern to this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([\w.-]+)/?$ profile.php?u=$1 [QSA,L]
\w
matches [a-zA-Z0-9_]
Upvotes: 2