所以我有以下重写规则:
RewriteRule ([^/]*)/([^/]*)/([^/]*)$ /index.php?grandparent=$1&parent=$2&page=$3
RewriteRule ([^/]*)/([^/]*)$ /index.php?&parent=$1&page=$2
RewriteRule ([^/]*)$ /index.php?page=$1
Run Code Online (Sandbox Code Playgroud)
但我需要这个不传递给某些子域的索引页面,所以我在此之前有以下重写条件:
RewriteCond %{REQUEST_URI} !^/css/.*$
RewriteCond %{REQUEST_URI} !^/js/.*$
RewriteCond %{REQUEST_URI} !^/admin/.*$
Run Code Online (Sandbox Code Playgroud)
因此,在查找这些目录中的任何文件时(包括可能位于这些目录的子目录中的文件),规则将不适用.但他们仍然在不断改写index.php
.
如何为这些目录创建例外?
你的RewriteCond应该是这样的:
RewriteCond %{REQUEST_URI} !^/(admin|js|css)/ [NC]
Run Code Online (Sandbox Code Playgroud)
另外,你必须在所有RewriteRule行中使用L
和QSA
标记,如下所示:
# skip these paths for redirection
RewriteCond %{REQUEST_URI} !^/(admin|js|css)/ [NC]
RewriteRule ^ - [L]
RewriteRule ([^/]*)/([^/]*)/([^/]*)/?$ index.php?grandparent=$1&parent=$2&page=$3 [L,QSA]
RewriteRule ([^/]*)/([^/]*)/?$ index.php?&parent=$1&page=$2 [L,QSA]
RewriteRule ([^/]*)/?$ index.php?page=$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6832 次 |
最近记录: |