douyanjing8287 2016-01-12 15:34
浏览 19

如何为子域设置虚拟主机?

I have a sub domain. I want to set up virtual host for it locally using xampp (apache).

For example I want to use test.mywebsite.com I want to run local files by opening this sub domain.

I have tried almost all articles/helping meterials online to setup sub domain for virtual host but in vain.

I tried following but nothing work:

httpd-vhosts.conf:

<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/project"
ServerName mywebsite.com
ServerAlias test.mywebsite.com

hosts file:

127.0.0.1 mywebsite.com
127.0.0.1 test.mywebsite.com

I'll appreciate for any suggestion/help. Thanks

  • 写回答

1条回答 默认 最新

  • donglue1886 2016-01-12 15:47
    关注

    Edit C:\xampp\apache\conf\extra\httpd-vhosts.conf and add the following lines. Make sure to replace dir with your original document root.

    <VirtualHost *:80>
        ServerName  test.mywebsite.com
        DocumentRoot "C:\xampp\htdocs\dir"
        <Directory "C:\xampp\htdocs\dir">
            DirectoryIndex index.php
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    

    Restart apache then edit C:\Windows\System32\Drivers\etc\hosts and add the following line at bottom.

    127.0.0.1 test.mywebsite.com

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度