Bug 47186 - must add [NE] to rewrite_guide.html#canonicalhost example
Summary: must add [NE] to rewrite_guide.html#canonicalhost example
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 2.2.11
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: HTTP Server Documentation List
URL: http://www.radioscanningtw.jidanni.or...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-12 14:19 UTC by Dan Jacobson
Modified: 2009-05-12 18:36 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Jacobson 2009-05-12 14:19:54 UTC
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html#canonicalhost
needs to be corrected as follows, or else it will fail outside of ASCII.
-RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]
+RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R,NE]
Otherwise the QUERY_STRING will get doubly escaped!:
$ set radioscanningtw.jidanni.org/index.php?title=%E9%A6%96%E9%A0%81\&uselang=en
$ w3m -dump http://$1|head
Jump to: navigation, search...
$ w3m -dump http://www.$1|head
The requested page title was invalid, empty, or an incorrectly linked...
$ HEAD -PS http://$1|head -n 2
HEAD http://radioscanningtw.jidanni.org/index.php?title=%E9%A6%96%E9%A0%81&uselang=en --> 200 OK
$ HEAD -PS http://www.$1|head -n 2
HEAD http://www.radioscanningtw.jidanni.org/index.php?title=%E9%A6%96%E9%A0%81&uselang=en --> 301 Moved Permanently
HEAD http://radioscanningtw.jidanni.org/index.php?title=%25E9%25A6%2596%25E9%25A0%2581&uselang=en --> 200 OK
(I will tell the MediaWiki people to return 404.)

The preceding is the situation on Dreamhost when one clicks their
"rewrite my URL without WWW" option on their control panel, and not the
product of junior programmer me. It also probably affects those who
chose their "Always add WWW" option.

So any of their hundreds of thousands of users are affected, the moment
any non ASCII is attempted... all presumably due to poor advice there in
the Apache manual, perhaps.

And the problem was not detected earlier because most of their users are
USA ASCII website making people, perhaps.

I will tell Dreamhost to have a look at this bug report.

However I would also like to note that on my home machine, I needed to change
-RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R,NE]
+RewriteRule   (.*) http://fully.qualified.domain.name/$1 [L,R,NE]
during my experiments too.
Comment 1 Rich Bowen 2009-05-12 18:33:33 UTC
That doesn't seem right at all. Surely the query string shouldn't be included in what RewriteRule matches at all. Adding [NE] certainly won't hurt, but I don't quite get why it would fix this particular problem.
Comment 2 Rich Bowen 2009-05-12 18:36:50 UTC
Done in r774161: although it won't do anything for the query string, it does indeed prevent URIs from getting double-escaped. Thanks for the report.