Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Geeky Chimp

macrumors regular
Original poster
Jun 3, 2015
132
59
I have a web app running behind an Apache reverse proxy. All is working well, except the web application uses a hashtag to determine which page is visited, eg: www.example.com/#/foo . If the user types this in all works well. If the user clicks a link to www.example.com/#/foo/bar the slashes are replaced with %2f (HTML encoded); www.example.com/#%2ffoo%2fbar . Whilst this works it looks ugly.
We also have a single reverse proxy exception; /baz .
There is also two URLs that do not use the hashtag, /static and /api .
Current Config:
ProxyPass /baz !
ProxyPass / http://127.0.0.1:8888/
ProxyPassReverse / http://127.0.0.1:8888/

Questions:
  1. How can I use Apache to replace the %2f to slashes, so that the user sees slashes instead? My assumption on rewrite rules is that they are before reverse proxy?
  2. Is there a way to replace the hashtag with nothing? eg www.example.com/#/foo becomes www.example.com/foo but the non hashtag URLs still work.

Any ideas? Thank you in advance!
 

shoulin333

macrumors 6502a
Jun 26, 2007
700
21
California
I am not extremely familiar with Apache reverse proxy but reverse proxies in general are my favorite way to nerd out... sad I know. I use IIS ARR URL ReWrite a ton but replacing "/" isn't something that is normal from my experience so there should be a way...

Check out: (I think they are solving a slightly different problem but I think from my understanding nocanon might be what you are looking for?) (Maybe not...)


Issue 3: mod_proxy attempts to re-encode (double encode) the URL changing %2F to %252F (eg. /example/http:%252F%252Fwww.someurl.com/)
Solution: In httpd.conf use the ProxyPass keyword nocanon to pass the raw URL thru the proxy.
ProxyPass http://anotherserver:8080/example/ nocanon

httpd.conf file:
AllowEncodedSlashes NoDecode

<Location /example/>
ProxyPass http://anotherserver:8080/example/ nocanon
</Location>

---

Source: https://stackoverflow.com/questions/4390436/need-to-allow-encoded-slashes-on-apache
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.