Reputation: 17
I've got a problem in my .htaccess using Rewrite Rule. Here's my .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/user/$ user.php?u=$1
The error is in the bottom two lines, where anybody going to /user/foo would see the result of going to /user?u=foo.
Upvotes: 1
Views: 22
Reputation: 80639
Try this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_FILENAME}.php [NC,L]
RewriteRule ^/?user/([\w-]+)/?$ user.php?u=$1 [L]
Upvotes: 1
Reputation: 18671
You can use:
RewriteEngine On
RewriteRule ^user/(.+)/?$ user.php?u=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Upvotes: 1