Reputation: 26565
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?username=$1 [L]
but I get error with the css and js files.
what I have to write in the htaccess ?
Upvotes: 3
Views: 46
Reputation: 64700
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]
Upvotes: 3
Reputation: 270775
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]
Upvotes: 2