Welcome! Log In Create A New Profile

Advanced

Nginx redirection

Posted by Enrico 
Enrico
Nginx redirection
May 16, 2018 08:30AM
Hi,

I have a nginx server (called mynginxserver) and need to redirect some urls
:

I want to have all url with the string tso:

http://www.mynginxserver.com/XXXXXXtsoXXXXX

redirected to

https://myserver.com/XXXXXXtsoXXXXX

if the string tso is in the url and redirect to

http://www.mynottsoserver.com/XXXXXXXXXXX

if the string tso is not present.

XXXXXXtsoXXXXX and XXXXXXXXXXX must be keep.
The string "tso" can ben anywhere in the last parameter (tsoXXXXX,
XtsoXXXX, XXXXtso, etc.)

I think i need to use the location and rewrite directive but don't know how
to do that.

Thanks for your help

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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Aleksandar Lazic
Re: Nginx redirection
May 23, 2018 05:10PM
Hi.

On 16/05/2018 02:22, Enrico wrote:
>Hi,
>
>I have a nginx server (called mynginxserver) and need to redirect some
>urls
>:
>
>I want to have all url with the string tso:
>
>http://www.mynginxserver.com/XXXXXXtsoXXXXX
>
>redirected to
>
>https://myserver.com/XXXXXXtsoXXXXX
>
>if the string tso is in the url and redirect to
>
>http://www.mynottsoserver.com/XXXXXXXXXXX
>
>if the string tso is not present.
>
> XXXXXXtsoXXXXX and XXXXXXXXXXX must be keep.
> The string "tso" can ben anywhere in the last parameter (tsoXXXXX,
>XtsoXXXX, XXXXtso, etc.)
>
>I think i need to use the location and rewrite directive but don't know how
>to do that.
>
>Thanks for your help

Please can you take a look into this documents.

https://nginx.org/en/docs/http/request_processing.html
https://nginx.org/en/docs/http/ngx_http_core_module.html#location
https://nginx.org/en/docs/varindex.html

I suggest two locations like this,untested.

```
location ~ tso {
return 302 https://myserver.com/$uri
}

location / {
return 302 https://www.mynottsoserver.com/$uri
}

```

Regards
Aleks

>Posted at Nginx Forum: https://forum.nginx.org/read.php?2,279813,279813#msg-279813
>
>_______________________________________________
>nginx mailing list
>[email protected]
>http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Enrico
Re: Nginx redirection
June 14, 2018 03:30PM
Hi,

Thanks for your help.

Your solution is good, my server works !

Thanks

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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login