我如何申请一个htaccess重写规则包含换行符(%0A)的URL? [英] How can I apply an htaccess rewrite rule to a URL containing a linefeed character (%0A)?

查看:476
本文介绍了我如何申请一个htaccess重写规则包含换行符(%0A)的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行到包含转义换行以下格式的不良网址:

I'm running into bad URLs that contain an escaped line-feed in the following format:

http://domain.com/%0Apath/to/file.txt

不过,即使我尝试最具全球性的重写可能......

However, even if I try the most global rewrite possible...

RewriteRule ^.*$ /path/to/file.txt [R=301,L]

...阿帕奇仍然抛出一个404:

...Apache still throws a 404:

The requested URL / path/to/file.txt was not found on this server.

(Note the space.)

我如何优雅地拦截这些不良网址,并将其路由到正确的目的地?

How can I gracefully intercept these bad URLs and route them to the right destination?

推荐答案

我有同样的问题。我固定它与sarumont的回答帮助。

I had the same Problem. I fixed it with the help of sarumont's answer.

例如URL,网站管理员工具中找到:

Example URL, found in Webmaster Tools:

/dummy-url/dummy-%0A%0Afull-version-download

这是我加入Apache的配置重写规则:

Rewrite Rule that I added in Apache config:

RewriteRule ^/dummy-url/dummy-[\n\r]+full-version-download$ /dummy-url/dummy-full-version-download [L,R=301]

这篇关于我如何申请一个htaccess重写规则包含换行符(%0A)的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆