Redirect Question for Directory Structure Change

figshta nginx-forum at forum.nginx.org
Thu Sep 10 04:25:50 UTC 2020


Thank you Reinis.

I really appreciate your help and your patience.
I am trying to learn this, so seeing what how it works is very useful.

To be clear, hopefully, I need all the (multiple) subdirectories of
threedaystubble.com/e/ in existing inbound links to refer to the new
structure threedaystubble.com/~

>p.s if there are multiple redirect locations (besides /e) an easy way is to
group them together via map directive.

All the redirect locations are in /e/. 
In fact the path to everything is the same except I removed the /e/. 
So, maybe I don't need to use the map directive, right?

This didn't work:

location ~ ^/e/(.*) { return 310 $scheme://threedaystubble.com/$1; }

This seems to work:

<rewrite ^/e/(.*) /$1 permanent;

Thank you, now I want to understand it.
I read that using return was less processor intensive, so I was hoping that
that one would have worked.

Somehow the rewrite seems wrong. 
I expected the browser to show the new location, but when I see the address
in the browser using the rewrite above it shows threedaystubble/e/~ even
though the files are not really in that location. 
I could have just as easily put the files in a /e/ as they were, but I don't
like that structure for various reasons, hence the change. 
The inbound links work, which is great, and if the new location is being
propagated (i.e. new inbound links won't be created in the future that refer
to /e/) then it's okay.

What do you think? Is what I want to do clear?

Thanks again.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,289363,289369#msg-289369



More information about the nginx mailing list