开发者

mod_rewrite, not rewriting when making a change

My mod_rewriting seems to be being messed up by this one line at the end of my .htaccess file, and I can't for the life of me work out why.

RewriteEngine ON
Options FollowSymLinks

# User profile with username specified
RewriteRule ^([a-z0-9_.-]{1,30}+)$ profile.php?username=$1 [NC,L]

I want to match usernames, but allow them to have a-z 0-9 (no case) and also allow underscores, dots and hyphens.

It works fine without the '_.-'

I've tried escaping them too, but to no avail.

EDIT:

It seems that the problem with the rewrite, is that it is causing my 'styles.css' file to be rewritten, even though I've got it set to NOT rewrite, if the file or directory exists.

Here's the whole .htaccess file...

RewriteEngine ON
Options FollowSymLinks

# Only rewrite for folders and directories that don't exist
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d

# Remove www.
RewriteCond %{HTTP_HOST} ^www.nitpicker.me$ [NC]
RewriteRule ^(.*)$ http://nitpicker.me/$1 [R=301]

# Remove the trailing slash if there is one
RewriteRule ^(.+)/$ $1

# Main pages
RewriteRule ^(stream|settings|comment|profile)(.php)?$ $1.php [QSA,L]

# Find friends page
RewriteRule ^friends$ findfriends.php [L]

RewriteRule ^subject-([0-9]+)$ page.php?subject_id=$1 [QSA,L]
RewriteRule ^nit-([0-9]+)$ comment.php?nit_id=$1

RewriteRule ^search-([a-z0-9]+)$ search.php?term=$1 [NC,L]

# The initial sign up page with invite code
RewriteRule ^signup(-([a-z0-9]+))?$ signup.php?invite=$2 [NC,L]

# Trending page
RewriteRule ^(newest|trending|most_picked) trending.php?select=$1 [QSA,L]

# User pr开发者_开发知识库ofile with username specified
RewriteRule ^([a-z0-9\-_\.]{1,30}+)$ profile.php?username=$1 [NC,L]

How can I get it to stop it rewriting my '/styles.css' file?


use this:

# User profile with username specified
RewriteCond %{REQUEST_URI} !^.*\.css.*$ [NC]
RewriteRule ^([a-z0-9\-_\.]{1,30}+)$ profile.php?username=$1 [NC,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜