我想像这样设置我的 htaccess:
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?slash1=$1&slash2=$2&slash3=$3&slash4=$4 [NC]
但保留某些不应受上述影响的目录,例如domain.com/banana 应该只是domain.com/banana 而不是带有slash1=banana 的index.php。
最佳答案
只需添加 RewriteCond 即可:
RewriteCond %{REQUEST_URI} !^/(banana|oranges|apple)(/.*|)$ [NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?slash1=$1&slash2=$2&slash3=$3&slash4=$4 [NC,L]
关于linux - .htaccess 重写重定向路径,但有异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16878549/