htaccess用斜杠代替反斜杠网址

htaccess用斜杠代替反斜杠网址

本文介绍了使用的.htaccess用斜杠代替反斜杠网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到反斜杠不应出现在在不是URL逃逸code以外的形式的URL,但是在这种情况下,URL被正由用于产生flashbooks .NET应用程序生成的。我所接触的这个应用程序的开发人员的bug报告。

在此期间我想使用的.htaccess重写有问题的反斜杠。

这是网址怎么会出现在小提琴手调试代理。

  www.example.com/folder/folder/thumbs%5C1.jpg
 

我使用Firefox和它看起来好像火狐被翻译成的URL连接codeD当量(\ ==%5C1)。有趣的是IE浏览器自动转换反斜线成正斜杠(不遵守标准,但方便的在这种情况下)。

有没有办法使用的.htaccess重写所有\到/?

解决方案

  RewriteEngine叙述上
的RewriteCond%{REQUEST_URI}(。*)\\(。*)
重写规则。*%1 /%2 [R = 301]
 

I realise that a backslash should never appear in a URL in a form other than a URL escape code, however in this case the URL's are being generated by a .NET application for generating flashbooks. I have contacted the developer of this application with a bug report.

In the interim i would like to use .htaccess to rewrite the offending backslashes.

This is how the URLs appear in fiddler debugging proxy.

www.example.com/folder/folder/thumbs%5C1.jpg

I am using Firefox and it looks as though Firefox is translating them into the URL encoded equivalent ( \ == %5C1 ). Interestingly IE translates the backslash into a forward-slash automatically (not adhering to standards but convenient in this case).

Is there a way to use .htaccess to rewrite all \ to /?

解决方案
RewriteEngine On
RewriteCond %{REQUEST_URI} (.*)\\(.*)
RewriteRule .* %1/%2 [R=301]

这篇关于使用的.htaccess用斜杠代替反斜杠网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 01:10