Welcome! Log In Create A New Profile

Advanced

RE: Redirect Question for Directory Structure Change

Reinis Rozitis
September 09, 2020 12:04PM
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


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Redirect Question for Directory Structure Change

figshta September 09, 2020 11:11AM

RE: Redirect Question for Directory Structure Change

Reinis Rozitis September 09, 2020 12:04PM

Re: RE: Redirect Question for Directory Structure Change

figshta September 10, 2020 12:25AM

Re: RE: Redirect Question for Directory Structure Change

figshta September 10, 2020 01:45AM

RE: RE: Redirect Question for Directory Structure Change

Reinis Rozitis September 10, 2020 04:18AM

Re: RE: RE: Redirect Question for Directory Structure Change

figshta September 10, 2020 06:34AM

RE: RE: RE: Redirect Question for Directory Structure Change

Reinis Rozitis September 10, 2020 07:18AM

Re: RE: RE: RE: Redirect Question for Directory Structure Change

figshta September 10, 2020 09:45AM

Re: RE: RE: RE: Redirect Question for Directory Structure Change

figshta September 10, 2020 11:18AM

Re: Redirect Question for Directory Structure Change

J.R. September 10, 2020 10:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 292
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready