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

前端 未结 2 761
清歌不尽
清歌不尽 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: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.

提交回复
热议问题