htaccess的,以逃避URL百分比(%) [英] htaccess to escape percent (%) from URL
问题描述
有百分号内的URL,将返回错误的请求(错误400)到浏览器。我有有百分之(%)符号的文件名,驻留在服务器
原文件名: 204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1,2%的.pdf
网址在浏览器中点击下载链接后:
的http://www.example.com/204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1%2C2%25.pdf
这将返回400错误与错误的请求。我使用的Kohana 3。
现有.htaccess文件内容如下:
RewriteEngine叙述上 的RewriteBase / <文件*> 订单拒绝,允许 禁止从所有 < /文件> 重写规则^(?:应用|模块|系统)。\ B *的index.php / $ 0 L] 的RewriteCond%{} REQUEST_FILENAME!-f 的RewriteCond%{} REQUEST_FILENAME!-d 重写规则。*的index.php / $ 0 PT]
尝试的 B标志,以确保 25%
,转义为%
由mod_rewrite的,是重新逃脱回到 25%
插入时回到目标路径。
重写规则。*的index.php / $ 0 PTB]
Having percent sign inside URL, returns bad request (error 400) to the browser. I have a file name that have percent (%) sign, resides at server.
Original File name: 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
This returns 400 error with bad request. I am using Kohana 3.
Existing .htaccess file contents are as follows:
RewriteEngine On RewriteBase / <Files .*> Order Deny,Allow Deny From All </Files> RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT]
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屋!