newbie needs help
Valentin V. Bartenev
vbart at nginx.com
Thu May 30 13:47:10 UTC 2013
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
More information about the nginx
mailing list