编码URL中的特殊字符使用htaccess的重写

编程入门 行业动态 更新时间:2024-10-28 02:22:05
本文介绍了编码URL中的特殊字符使用htaccess的重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个重写规则如下,它工作:

I have a rewrite rule as following,it is working:

RewriteRule area/(.*) listing.php?area=$1

但是,当我想用​​ 29%在里面,但是当我把它改写如下,我得到404错误:

But when I want to use %29 in it,but when I rewrite it as following, I get 404 error:

RewriteRule area/something%29/(.*)/ listing.php?area=$1

逃逸 29%为 \%29 也不能工作。

推荐答案

阿帕奇%-de codeS尝试应用重写规则之前的URL路径。所以,你不应该使用%编码在你的重写规则。只需使用普通字符。

Apache %-decodes the url-path before trying to apply the rewrite rules. So you should not use %-encoding in your RewriteRule. Just use the normal character.

所以,你的情况,你应该只使用了)。 )不过是普通的前pression特殊字符,所以你应该在前面加上一个反斜杠那些在正则表达式的方式。因此,这将成为 \)。

So in your case you should just use the ). ) however is a special character in regular expression, so you should escape those in the RegEx way by adding a slash in front. So it will become \).

上面你的规则应该成为:

Your rule above should become:

RewriteRule area/something\)/(.*)/ listing.php?area=$1

更多推荐

编码URL中的特殊字符使用htaccess的重写

本文发布于:2023-11-01 19:41:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550228.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   特殊字符   URL   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!