dongxiaoyan4388 2015-06-27 10:24
浏览 35

使用带有子域的PHP内置服务器

I'm used to use php -S 0.0.0.0:8080 while developing, because it saves me some time configuring a real web server. Until today I didn't miss anything about it, but now I need to develop a function that uses subdomains.

I must access http://foo-bar.localhost:8080 and make php see the request, because I'm trying to implement this.

Also, foo-bar is dynamic (like the language subdomain in the documentation of Yii2 I linked) so I need php to be able to handle all subdomains of localhost.

Is that possible? How?

  • 写回答

1条回答 默认 最新

  • dongleman4760 2016-12-17 11:28
    关注

    The first, i learn english is very bad, sorry if my answer is bad!!

    Your problem is test website support subdomain? i think it is relate dns!!

    solution for this in here:

    For Windows:

    Step 1: open C:\windows\system32\drivers\etc\hosts in text editor with Administrator permission

    Step 2: add 127.0.0.1 *.localhost to new line

    Step 3: save hosts file!

    Final, the Windows PC already for multi subdomain (ex: foo-bar.localhost:8080)

    If you using linux, see the article http://stackoverflow.com/a/20446931, it same above!

    If you cannot using any way, you can use my subdomain!

    both local.kingdark.org and *.local.kingdark.org are config for 127.0.0.1, but this way require internet! you can try it for test your website!! (ex: http://foo-bar.local.kingdark.org:8080)

    It safe and free!! 8-)

    Goodluck!

    评论

报告相同问题?