htaccess+modrewrite issue
I want that every user has a profile-url like this:
www.example.com/username
I have created this htaccess:
RewriteEngine on
RewriteRule ([^/]+) profile.php?userna开发者_开发技巧me=$1 [L]
but I get error with the css and js files.
what I have to write in the htaccess ?
You should in general exclude all real files and directories, as this will handle css/js/images/whatever else you want to serve:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ profile.php?username=$1 [L]
Exclue js and css with RewriteCond
.I think this should do:
RewriteEngine On
RewriteCond %{REQUEST_URI} ! \.(js|css)$ [NC]
RewriteRule ([^/]+) profile.php?username=$1 [L]
If you have images as well, add their extensions
RewriteCond %{REQUEST_URI} ! \.(js|css|jpg|gif|ico|png|whatever)$ [NC]
精彩评论