且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

htaccess的,以逃避URL百分比(%)

更新时间:2023-10-25 22:27:52

尝试的 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]