Welcome! Log In Create A New Profile

Advanced

Re: newbie needs help

Valentin V. Bartenev
May 30, 2013 09:48AM
On Thursday 30 May 2013 16:25:18 angelochen960 wrote:
> Thanks for the reply, it works, and also I read again those references. a
> related issue, say:
>
> if somebody enter this url in the browser: http://sample.com/not_exist_url
>
> and I'd like to redirect it to
>
> http://sample.com/
>
> with the try_files approach, index.html got displayed, that's right, but
> the url in browser still remain as http://sample.com/not_exist_url, i'm
> looking for a 302 i believe, any suggestions? thanks.
>

Yes, you're looking for an external redirect, that is completely
different thing. Then this config will serve your needs:

server {
listen 80;
server_name sample.com;

root /var/www/sample/public_html;

location = / {
try_files /index.html =404;
}

location / {
return 302 /;
}
}

Reference:

- http://nginx.org/r/return
- http://nginx.org/r/try_files
- http://nginx.org/r/location

wbr, Valentin V. Bartenev

--
http://nginx.org/en/donation.html

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

newbie needs help

angelochen960 May 30, 2013 06:02AM

Re: newbie needs help

Valentin V. Bartenev May 30, 2013 06:26AM

Re: newbie needs help

angelochen960 May 30, 2013 08:25AM

Re: newbie needs help

Valentin V. Bartenev May 30, 2013 09:48AM

Re: newbie needs help

angelochen960 May 30, 2013 10:19AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 62
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready