Redirect Question for Directory Structure Change
Reinis Rozitis
r at roze.lv
Wed Sep 9 16:03:19 UTC 2020
It is a bit unclear if you want only a single rewrite or are there multiple different directory mappings/redirects.
> I tried a couple of ideas, but they didn't work, I thought this location directive
> inside a server block was best, but it didn't work.
>
> location = /e {
> return 310 $scheme://threedaystubble.com; }
This means that only '/e' will be redirected and not '/e/site.html' (and not even '/e/') and it won't preserve the request uri.
This should work:
location ~ ^/e/(.*) { return 310 $scheme://threedaystubble.com/$1; }
Or you could do it via rewrite in the server {} block:
rewrite ^/e/(.*) /$1 last;
(you can replace the 'last' to 'permanent' if you want the client to know about the structure change and get the 301 redirect).
p.s if there are multiple redirect locations (besides /e) an easy way is to group them together via map directive.
rr
More information about the nginx
mailing list