# Why is # rewritten to %23?

**URL:** <https://www.ruby-forum.com/t/why-is-rewritten-to-23/214608>\
**Category:** NGINX\
**Created:** [December 7, 2011, 6:48am UTC](https://www.ruby-forum.com/t/why-is-rewritten-to-23/214608 "2011-12-07T06:48:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [December 7, 2011, 6:48am UTC](https://www.ruby-forum.com/t/why-is-rewritten-to-23/214608/1 "2011-12-07T06:48:16Z")

</div>

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/ (127.0.0.1) 0.30ms

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

---

<div class="post-metadata">

**Author:** ![Ted\_Lemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85e7bf/32.png) [@Ted\_Lemon](https://www.ruby-forum.com/u/Ted_Lemon)\
**Post date:** [December 7, 2011, 11:16am UTC](https://www.ruby-forum.com/t/why-is-rewritten-to-23/214608/2 "2011-12-07T11:16:01Z")

</div>

%23 is the ASCII Hexidecimal equivalent to #.  
See [HTML Codes - Table of ascii characters and symbols](http://www.ascii.cl/htmlcodes.htm) for the full list of codes.  
John

John Kennedy

---

<div class="post-metadata">

**Author:** ![Ted\_Lemon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85e7bf/32.png) [@Ted\_Lemon](https://www.ruby-forum.com/u/Ted_Lemon)\
**Post date:** [December 7, 2011, 3:36pm UTC](https://www.ruby-forum.com/t/why-is-rewritten-to-23/214608/3 "2011-12-07T15:36:04Z")

</div>

On Dec 7, 2011, at 5:15 AM, John Kennedy wrote:

> %23 is the ASCII Hexidecimal equivalent to #.

Yes, of course. What I meant was why is it encoding it and not leaving  
it as I wrote it?
