htaccess 从 URL 转义百分比 (%) [英] htaccess to escape percent (%) from URL
本文介绍了htaccess 从 URL 转义百分比 (%)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 URL 中有百分号,会向浏览器返回错误的请求(错误 400).我有一个带有百分比 (%
) 符号的文件名,位于服务器上.
Having percent sign inside URL, returns bad request (error 400) to the browser. I have a filename that have percent (%
) sign, resides at server.
原始文件名:
204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1,2%.pdf
点击下载链接后浏览器中的网址:
URL in browser after clicking on download link:
http://www.example.com/204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1%2C2%25.pdf
这将返回 400 错误并带有错误的请求".我正在使用 Kohana 3.
This returns 400 error with "bad request". I am using Kohana 3.
现有.htaccess
文件内容如下:
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
RewriteRule ^(?:application|modules|system).* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
推荐答案
试试 B 标志 以确保 %25
被 mod_rewrite 转义为 %
时,重新转义回 %25
插入回目标路径.
Try the B flag to ensure the %25
, unescaped to %
by mod_rewrite, is re-escaped back to %25
when inserted back into the target path.
RewriteRule .* index.php/$0 [PTB]
这篇关于htaccess 从 URL 转义百分比 (%)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文