我正在尝试使用以下方法重定向:

RewriteRule ^reviews/area/Santa-Barbara%2F$"/reviews/area/santa-barbara" [R=301,NC,L]

我打开了 AllowEncodedSlashes 指令,但重写仍然无效。我错过了什么?

最佳答案

您需要首先在服务器配置中使用 AllowEncodedSlashes directive 并将其设置为:

AllowEncodedSlashes NoDecode

然后在您的根目录 .htaccess 中,您可以使用以下规则:
RewriteEngine On

RewriteRule ^(reviews/area/Santa-Barbara)\%2f$ /$1 [R=301,NC,L]

关于.htaccess 重写 %2f,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25745832/

10-13 02:44