Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Having percent sign inside URL, returns bad request (error 400) to the browser. I have a filename 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).* index.php/$0 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT] 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
598 views
Welcome To Ask or Share your Answers For Others

1 Answer

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]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...