mod_rewrite已禁用对根文档中文件夹的访问权限

时间:2014-09-25 19:38:51

标签: regex apache .htaccess mod-rewrite

我创建了以下适用的规则:

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$           /search?type=$1&query=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$   /search?type=$1&query=$2&condition=$3 [L]

这会进行以下转换

/title/limitless   =  /search?type=title&query=limitless

但现在问题是我无法访问根文档中其他文件夹的资源,例如/images/css

我做错了什么?

1 个答案:

答案 0 :(得分:1)

让你的规则忽略文件/目录的重写:

Options +FollowSymLinks -MultiViews
RewriteEngine On

# skip all rules for real files and directories
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([^/]+)/?$         /search?type=$1&query=$2 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /search?type=$1&query=$2&condition=$3 [L,QSA]