在我的.htaccess文件的末尾,我的mod_rewriting似乎被这一行搞砸了,我不能为我的生活解决原因。
RewriteEngine ON
Options FollowSymLinks
# User profile with username specified
RewriteRule ^([a-z0-9_.-]{1,30}+)$ profile.php?username=$1 [NC,L]
我想匹配用户名,但允许他们使用a-z 0-9(无大小写)并且还允许使用下划线,点和连字符。
没有'_.-'
,它可以正常工作我也试过逃避它们,但无济于事。
编辑:
重写的问题似乎是它导致我的'styles.css'文件被重写,即使我将它设置为NOT rewrite,如果文件或目录存在。
这是整个.htaccess文件......
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 profile with username specified
RewriteRule ^([a-z0-9\-_\.]{1,30}+)$ profile.php?username=$1 [NC,L]
如何让它停止重写我的'/styles.css'文件?
答案 0 :(得分:3)
使用它:
# User profile with username specified
RewriteCond %{REQUEST_URI} !^.*\.css.*$ [NC]
RewriteRule ^([a-z0-9\-_\.]{1,30}+)$ profile.php?username=$1 [NC,L]