我有一个重写规则,只需要应用于深度不超过1个文件夹的网址
example.com/a >> rewrite me
AND NOT
example.com/a/b >> don't rewrite me
所以我只需要重写深度为1的网址。允许更大的深度,但需要不加改变。
我如何做一个Mod_Rewrite条件语句?我在哪里可以写出我的个人重写规则。 谢谢!
答案 0 :(得分:1)
RewriteEngine on
# Matches URLs which are equal to: "", "<text>", or "<text>/"
# if it matches, the rewrite engine does not attempt to match any more patterns
RewriteRule ^[^/]*/?$ - [L]
# If the above doesn't match, meaning it's depth is more than one,
# it forbids the content from being delivered
RewriteRule .* - [F]
答案 1 :(得分:0)
好笑,我只是在玩这样的表情。
RewriteRule ^[^\/]+$ - [L]
我相信这就是你所说的。