Home  >  Q&A  >  body text

nginx - related issues about domain name jump

Question 1: If I have a domain name abc.com, now I want to automatically jump to about when I type abc.com in the browser. abc.com, just like the official website of gitlab.

What steps are needed to achieve this effect?
What knowledge is needed?

Question 2: If I now have a domain name abc.com, there are two folder directories under the html directory of nginx, one is bbs, one is wiki, how to set it up to access under the bbs directory when accessing bbs.abc.com index, what about opening index in the wiki directory when visiting wiki.abc.com?

What steps are needed to achieve this effect?
What knowledge is needed?

Note: I will learn Nginx, but I hope you can give me the knowledge I need first, or give me some tips and tell me what knowledge and steps are needed to achieve it. Thank you.

某草草某草草2714 days ago482

reply all(4)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 17:13:08

    Question 1

    Too many methods

    • The easiest thing is to set it during DNS resolution301跳转或者302跳转,将abc.com跳转到about.abc.com

    • can also be set in nginx

    server {
            listen 80;
            server_name abc.com;
    
            return 301 https://about.abc.com$request_uri;
    }
    • can also be set in the code, such as in js中指定window.locatioin, the back-end language response returns 301 and location, etc.

    Question 2

    server {
            listen 80;
            server_name bbs.abc.com;
            root path/to/bbs
            index index.php index.html
            
            #其他配置...
    }
    server {
            listen 80;
            server_name wiki.abc.com;
            root path/to/wiki
            index index.php index.html
            
            #其他配置...
    }

    In fact, you don’t need much knowledge or steps. You can achieve the effect you want by just searching online. If you want to go deeper, please google for question 1url redirect 301 302 nginx 显式跳转 隐式跳转等关键词
    问题2请googlenginx 配置文件

    reply
    0
  • 为情所困

    为情所困2017-05-16 17:13:08

    Use keywords:
    nginx domain name redirection

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:13:08

    For question 1: Most resolution service providers have the "explicit URL forwarding" function. You can put abc.com解析到about.abc.com.

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 17:13:08

    Just a little google and you will get the answer immediately http://guge.suanfazu.com/sear...

    reply
    0
  • Cancelreply