Score:0

Nginx: URL rewrite with proxy_pass and URL parameters and special chars

pl flag

I studied all the great posts to nginx proxy and rewrite functionality, but was unable to find a solution for my problem. So here we are. I wrote an web application with vaadin, that is able to handle the follwoing request:

http://<server>/#main/search?country=germany&type=songwriter

For SEO optimization, I want to handle "speaking" urls, like: http:///songwriter/germany. So I thought URL rewriting within the web-server is the solution. But whatever I tried, I am unable to place the hashtag within the request and to form the final solution! Here is what I tried:

  location  /songwriter/ {
        proxy_set_header Host $host;
        proxy_redirect off;
        # Option 1 - hastag is encoded
        rewrite ^/songwriter/(.+) /#main/suche?land=$1  break;
        proxy_pass http://127.0.0.1:8080; 
 }

What I get in the trace is: /%23main/suche land=berlin/. Any idea?

Score:1
cz flag

The URL fragment is client side only and is never sent to the server. (Because the literal # is not allowed there, nginx URL encodes it.) If your web app abuses URL fragments for navigation then they can only be handled by your client side (in browser) code. Note that using URL fragments in this way is not considered good practice. You will probably have to significantly rewrite your web application to get rid of them.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.