htaccess的 - 从以下网址地带字符“%26”字符、地带、网址、htaccess

2023-09-02 09:46:03 作者:人不风流枉少年

我已经有很长一段时间的读者,但是这是我的第一篇文章。通常情况下,我可以谷歌和问题解决我的方式,通过我有什么问题,但是这一次采取了我很多时间,我很茫然。

I have been a long time reader but this is my first post. Normally I can google and problem solve my way through any issues I have, but this one has taken me many hours and I am at a loss.

从好的方面我已经学到了很多有关的.htaccess code妆,而不是所有的剪切和粘贴我一直在做的这些年。

On the plus side I have learnt much about the makeup of .htaccess code as opposed to all the cutting and pasting I have been doing all these years.

眼下的问题是,我从一个旧的CMS系统迁移到一个新的。旧的系统中显示的[安培]符号字符的URL在他们的十六进制格式,%26。新型农村合作医疗制度这条完全。我一直在试图通过重写规则删除此。

The issue at hand is that I am moving from an old CMS system to a new one. The old system displayed [&] ampersand characters in the url in their hex format, '%26'. The new CMS system strips this completely. I have been trying to remove this through a rewrite rule.

The objective is to make this url:
http://domain.com.au/drums-%26-percussion/

Redirect to this:
http://domain.com.au/drums-percussion/

我已经试过无数的线条组合,但是这两个例子都已经最接近我能得到它的工作。

I have tried numerous lines and combinations, but these two example are have been the closest I could get to it work.

Example A)
RewriteRule ^(.*)%26(.*)$ http://domain.com.au/$1-$2 [L,NE,N,R=301]

这上面的例子中工作,如果我实际使用和放大器;,而不是十六进制格式%26。出于某种原因不明给我,我不能让它火。例如,没有任何反应。我已经绕%疲惫这么多的变化26。

This above example works if I actually use the &, not the hex format %26. For some reason unknown to me I cannot get it fire. eg, nothing happens. I've tired so many variations around the %26.

Example B)
RewriteCond %{THE_REQUEST} ^(.*)(-%26-)(.*)  [NC]
RewriteRule ^ http://domain.com.au/$1-$2 [L,NE,R=302]

我曾经读过的26%必须投入的条件被拾起。所以,我想这一点。它读取26%和火灾关闭重定向。问题是我没有通过在$ 1 $ 2的值。最终的结果我得到这个code是:

I read somewhere that the %26 had to be put into a condition to be picked up. So I tried this. It reads the %26 and fires off the redirect. The issue is I am not passing on the $1 $2 values. The end result I am getting with this code is:

Start:
http://domain.com.au/drums-%26-percussion/
Redirect:
http://derringers.testpad.com.au/-  

我AP preciate任何和所有的建议是这件事情。谢谢。

I appreciate any and all advice is this matter. Thank you.

推荐答案

作为的文档规定:

在第一个重写规则,它匹配的(%-de codeD)请求的URL路径。

On the first RewriteRule, it is matched against the (%-decoded) URL-path of the request.

这意味着该URL您在浏览器看到:

This means that the URL you see in browser as:

http://domain.com.au/drums-%26-percussion/

,事实上:

http://domain.com.au/drums-&-percussion/

重写规则尝试匹配 / drums-和放大器; -percussion

鉴于这种情况,正确的重写规则相匹配的网址为:

Given that, the correct RewriteRule to match the URL is:

RewriteRule ^(.*)-&-(.*)$ http://domain.com.au/$1-$2 [L,NE,N,R=301]