我试图做这样RewriteEngine叙述和类别链接
business/index.html
business/
business
东西打开categories.php?prefix=$1
我已经习惯
RewriteRule ^([A-Za-z0-9-]+)/?(index.html)?$ categories.php?prefix=$1 [QSA,L]
了伟大的工作,但是当打开/ ADMIN其一个真实的文件夹,它把它看作一个类别 我怎么能排除这个
我试图做这样RewriteEngine叙述和类别链接
business/index.html
business/
business
东西打开categories.php?prefix=$1
我已经习惯
RewriteRule ^([A-Za-z0-9-]+)/?(index.html)?$ categories.php?prefix=$1 [QSA,L]
了伟大的工作,但是当打开/ ADMIN其一个真实的文件夹,它把它看作一个类别 我怎么能排除这个
Thi s会查看路径是否以admin
或images
开头。如果有,规则将不适用。如果不是(即如果它与别的开始),该规则将适用:
# Only apply to files that exist (uncomment to use):
#RewriteCond %{REQUEST_FILENAME} -f
# Only apply if the request is NOT for a directory (uncomment to use):
#RewriteCond %{REQUEST_FILENAME} !-d
# Only apply when the requested URI begins with admin or images (Not Case-sensitive):
RewriteCond %{REQUEST_URI} !^(/[admin|images]/) [NC]
# If all conditions are met, apply the following rule:
RewriteRule ^([A-Za-z0-9-]+)/?(index.html)?$ categories.php?prefix=$1 [QSA,L]
如果我想添加更多? admin和images –
你的意思是'/ admin/images'或'/ admin'和'/ images'分开吗? – jerdiggity
及其不工作 –
你可以这样做:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-]+)/?(index.html)?$ categories.php?prefix=$1 [QSA,L]
这将改写所有网址,除非真正的文件夹或文件被打开。
你只需要这个'admin',还是所有现有的文件夹?如果是后者,则在“RewriteCond%{REQUEST_FILENAME}!-d”行前加上该规则。 – raina77ow
@ raina77ow请给我代码 –
你是什么意思?它是代码。在'RewriteRule'的行之前用'RewriteCond'添加该行。 – raina77ow