How to test sub-domains on my localhost on a mac?

前端 未结 2 759
清歌不尽
清歌不尽 2021-01-17 16:15

I have set up a web application on I am running it on my localhost. That is - http://127.0.0.1:8000/. I have set up sub-domains as well. For example, going to http://blog.12

相关标签:
2条回答
  • 2021-01-17 16:49

    Edit the file /etc/hosts, add the following line:

    127.0.0.1 example.com blog.example.com
    

    Then try http://example.com:8000/ and http://blog.example.com:8000/

    0 讨论(0)
  • 2021-01-17 16:50

    Must be adding to file /etc/hosts

    127.0.0.1       localhost blog.localhost lvh.me blog.lvh.me
    

    Example for Vim editor (small overview about work in Vim)

    1. Run to edit file /etc/hosts:

      sudo vim /etc/hosts
      
    2. In Vim press on keyboard button i to switch on edit mode

    3. Add this line:

      127.0.0.1       localhost blog.localhost lvh.me blog.lvh.me
      
    4. Save file:

      • Press button Esc and after press together buttons shift :

      • Now you will see line in which write x and press Enter

    Thats all, blog.localhost and blog.lvh.me is already available for all ports that you are using.

    0 讨论(0)
提交回复
热议问题