map problem : how to debug it ?
Igor Ippolitov
iippolitov at nginx.com
Wed Apr 13 10:45:15 UTC 2022
Gilles,
When you enter a url with an anchor into a browser, the browser will
only request a URL without the anchor from the web server.
The web servers gets only the part you see in logs.
For '/Doc.html#case1' the web server will receive a request for
'/Doc.html'. The anchor is used by the browser itself to navigate within
a page.
You can't rely on the anchor part to make decisions on the web server side.
AFAIK, the anchors were initially to scroll to a an element with a
corresponding ID.
Later it was reused by JS frameworks to build navigation within so
called single page applications.
This link may help:
https://en.wikipedia.org/wiki/Single-page_application#Browser_history
(note that it also uses an anchor ;)
To sum it up: there is no solution to the problem you are asking about.
But most likely this is an XY problem:
https://en.wikipedia.org/wiki/XY_problem .
Hope this helps,
Igor.
On 13.04.2022 10:41, gperrot wrote:
> Thanks a lot for all your answers !
>
> Since I have the case below with anchor (fragment-ID in URL to map to one
> specific action in my doc.map :
>
> /Doc.html#case1 https://domain2.com/action1;
> /Doc.html#case2 https://domain2.com/action2;
> /Doc.html https://domain2.com/action3;
>
> How can I do this kind of mapping with Nginx ?
>
> For the moment, my conf is :
> map $uri $new_uri {
> include /etc/nginx/conf/doc.map;
> }
>
> If I type https://domain1.com/Doc.html, the map for action3 works but if I
> type https://domain1.com/Doc.html#case1 or
> https://domain1.com/Doc.html#case2, the map doesn't work.
>
> Any idea how to solve that ?
>
> Thanks in advance for your help.
>
> Gilles
>
> Posted at Nginx Forum: https://forum.nginx.org/read.php?2,293930,293948#msg-293948
>
> _______________________________________________
> nginx mailing list -- nginx at nginx.org
> To unsubscribe send an email to nginx-leave at nginx.org
More information about the nginx
mailing list