Why is # rewritten to %23?

Ted Lemon mellon at fugue.com
Wed Dec 7 05:47:46 UTC 2011

I've got a rewrite rule in my nginx config file to convert from an old URL to a new one, but the new URL has a hash string in it, and it doesn't seem to be possible to get nginx to rewrite that without encoding it.

The relevant rewrite rule is this:

                location /contact/dmes/term {
                        rewrite "/contact/dmes/term/(.*)" "/#term=$1";  

This then goes through the following proxy:

                location / {
                        proxy_pass_header Server;
                        proxy_set_header Host $http_host;
                        proxy_redirect off;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Scheme $scheme;
                        proxy_pass http://tornado;

The URL that the proxied http server gets is this (as it appears in the log):

WARNING:root:404 GET /%23term=14/ ( 0.30ms

Is there some way to disable this behavior?   Have I violated some terrifying taboo?   Thanks for any advice/flames!

More information about the nginx mailing list