Welcome! Log In Create A New Profile

Advanced

How to stop nginx from adding a trailing slash

Posted by Gregory Edigarov 
Gregory Edigarov
How to stop nginx from adding a trailing slash
March 09, 2018 03:10PM
Hello,

somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.

this is not the behaviour i want.

is there any way to stop it from doing so?


Thank you.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Igor Sysoev
Re: How to stop nginx from adding a trailing slash
March 09, 2018 04:00PM
> On 9 Mar 2018, at 17:06, Gregory Edigarov <[email protected]> wrote:
>
> Hello,
>
> somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.
>
> this is not the behaviour i want.
>
> is there any way to stop it from doing so?

A special location for "/blog":

location = /blog {
...
}

location /blog/ {
...
}


--
Igor Sysoev
http://nginx.com

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Gregory Edigarov
Re: How to stop nginx from adding a trailing slash
March 09, 2018 05:20PM
On 09.03.18 16:52, Igor Sysoev wrote:
>> On 9 Mar 2018, at 17:06, Gregory Edigarov <[email protected]> wrote:
>>
>> Hello,
>>
>> somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.
>>
>> this is not the behaviour i want.
>>
>> is there any way to stop it from doing so?
> A special location for "/blog":
>
> location = /blog {
> ...
> }
>
> location /blog/ {
> ...
> }
>
>
sorry, doesn't work...

It somehow seems to me, some time ago there was an option, to switch the
related behaviour.
but may be it is my false memory.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Igor Sysoev
Re: How to stop nginx from adding a trailing slash
March 09, 2018 10:00PM
> On 9 Mar 2018, at 19:17, Gregory Edigarov <[email protected]> wrote:
>
> On 09.03.18 16:52, Igor Sysoev wrote:
>>> On 9 Mar 2018, at 17:06, Gregory Edigarov <[email protected]> wrote:
>>>
>>> Hello,
>>>
>>> somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.
>>>
>>> this is not the behaviour i want.
>>>
>>> is there any way to stop it from doing so?
>> A special location for "/blog":
>>
>> location = /blog {
>> ...
>> }
>>
>> location /blog/ {
>> ...
>> }
>>
>>
> sorry, doesn't work...
>
> It somehow seems to me, some time ago there was an option, to switch the related behaviour.
> but may be it is my false memory.

It should work. 301 redirect is usually cached by browser for long time.
Try curl, another browser or try to clean cache.


--
Igor Sysoev
http://nginx.com

_______________________________________________
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