如何有条件地使我的.htaccess跳过规则?

pix*_*ine 0 apache .htaccess mod-rewrite skip

我想将所有不包含"_js","_ css","_ img"等的URL重定向到我的调度脚本.不知怎的,它不起作用.例如,我的/ _js /文件夹中的所有文件都是无法访问的(这意味着:它们被发送到index.php而不是到达驻留在该文件夹中的物理文件).

这是我的htaccess:

IndexIgnore *
Options +FollowSymLinks
RewriteEngine on

# if the following conditions are met, SKIP the rewriteRules.

RewriteCond %{REQUEST_URI} ^/(_admin/¦_css/¦_js/¦_img/)
RewriteRule . - [S=9]


# Externally redirect to add missing trailing slash
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://%{HTTP_HOST}/$1/?%{QUERY_STRING} [NC,R,L]

# SIX PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?section=$1&item=$2&menu=$3&content=$4&id=$5&title=$6&%{QUERY_STRING} [NC,L]

# FIVE  PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?section=$1&item=$2&menu=$3&content=$4&id=$5&%{QUERY_STRING} [NC,L]

# FOUR PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?section=$1&item=$2&menu=$3&content=$4&%{QUERY_STRING} [NC,L]

# THREE PARAMS : projects/touch/texts/
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /index.php?section=$1&item=$2&menu=$3&%{QUERY_STRING} [NC,L]

# TWO PARAMS: downloads
RewriteRule ^downloads/([^/]+)/$ index.php?section=downloads&item=$1&%{QUERY_STRING}  [NC,L]

# TWO PARAMS:
RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?section=$1&item=$2&%{QUERY_STRING} [NC,L]

# TAG URL : index.php?tag=space%2C+navigable+music#5
RewriteRule ^tag/([a-z0-9_\-]+)/$ index.php?tag=$1&%{QUERY_STRING} [NC,L]
# ONE PARAM
RewriteRule ^([a-z0-9_\-]+)/$ index.php?section=$1&%{QUERY_STRING} [NC,L]
Run Code Online (Sandbox Code Playgroud)

编辑:

注意我的文件夹结构.它可能是问题来源吗?

我有一个"v1"和"v2"文件夹结构.这个.htaccess位于"v2"文件夹中.上面一级,我有一个.htaccess,将所有请求重定向到"v2".

root 
  L.htaccess << dispatch between v1 and v2 folders 
  L v1 L v2 L.htaccess << the .htaccess code posted above 
  L _admin L all my website files & folders
Run Code Online (Sandbox Code Playgroud)

Gum*_*mbo 5

您正在使用错误的字符¦(断条,U + 00A6)而不是|(垂直线,U + 007C),以及错误的图案REQUEST_URI.

RewriteCond %{REQUEST_URI} ^/v2/(_admin/|_css/|_js/|_img/)
RewriteRule . - [S=9]
Run Code Online (Sandbox Code Playgroud)

或者对于v2目录中的.htaccess文件:

RewriteRule ^_(admin|css|js|img)/ - [S=9]
Run Code Online (Sandbox Code Playgroud)