Nginx跳转到用户首页
生活随笔
收集整理的這篇文章主要介紹了
Nginx跳转到用户首页
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
經(jīng)常有這樣的需求,當(dāng)用戶輸入某個網(wǎng)站的域名時(如kanban.chexindata.com),默認(rèn)會跳轉(zhuǎn)到用戶首頁(http://kanban.chexindata.com/index),那么這個功能用nginx是怎樣實現(xiàn)的呢?這里,我的思路是用rewrite功能,先判斷uri是否僅僅是域名,如果是,重寫即可。
server {listen 80;server_name kanban.chexindata.com;charset utf-8;location / {proxy_pass http://183.17.229.91:18002;proxy_redirect off;proxy_intercept_errors on;proxy_set_header Host $host;proxy_connect_timeout 90;proxy_send_timeout 90;proxy_read_timeout 90;proxy_buffer_size 40k;proxy_buffers 4 320k;proxy_busy_buffers_size 640k;proxy_ignore_client_abort on;client_max_body_size 10m;client_body_buffer_size 328k;}# 跳轉(zhuǎn)到用戶首頁(先判斷uri是否僅僅是域名,如果是,重寫即可)if ( $request_uri = "/" ){return 301 /index;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;} }總結(jié)
以上是生活随笔為你收集整理的Nginx跳转到用户首页的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 问题解决:下载的网页打开后自动跳转到首页
- 下一篇: 深入理解PHP原理之PHP与WEB服务器