htaccess to escape percent (%) from URL

匆匆过客 提交于 2019-11-27 08:06:05

问题


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] 

回答1:


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]


来源:https://stackoverflow.com/questions/3996726/htaccess-to-escape-percent-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!