Linux .htaccess重写重定向路径时出现异常
我想这样设置我的htaccess:Linux .htaccess重写重定向路径时出现异常,linux,.htaccess,Linux,.htaccess,我想这样设置我的htaccess: RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?slash1=$1&slash2=$2&slash3=$3&slash4=$4 [NC] 但保留某些不应受上述影响的目录,例如domain.com/banana应该只指向domain.com/banana,而不是带有slash1=banana的index.php。只需添加如下重写条件: RewriteCond %{REQUES
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?slash1=$1&slash2=$2&slash3=$3&slash4=$4 [NC]
但保留某些不应受上述影响的目录,例如domain.com/banana应该只指向domain.com/banana,而不是带有slash1=banana的index.php。只需添加如下重写条件:
RewriteCond %{REQUEST_URI} !^/(banana|oranges|apple)(/.*|)$ [NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?slash1=$1&slash2=$2&slash3=$3&slash4=$4 [NC,L]
谢谢在有多个例外的情况下,您如何做到这一点?例如香蕉、橘子和苹果……你可以在serverfault.com上找到更好的答案