網站部署頂層網域、次層網域、子網域名稱

來源:互聯網
上載者:User

標籤:

關於網域名稱介紹:

一般來說,一個完整的網域名稱用二個或者二個以上部分組成,各部分之間用英文的句號“.”開分割。如“www.baidu.com”,其中最後一個“.”的右邊部分“.com”成為頂級網域名稱(TLD,也成為頂層網域,類似還有.cn,.net,.org,.gov,.edu,.tv等等,這裡.com.cn其實是.cn下的次層網域)。任何個人都可以註冊一個.com網域名稱,其中baidu.com也就是頂級網域名稱.com下的次層網域,baidu.com還可以有image.baidu.com、music.baidu.com的形式,這裡的image\music可以稱為“子網域名稱”;

次層網域和子網域名稱的Apache配置:

進入Apache-conf-extra-httpd-vhost.conf,添加如下配置:

<VirtualHost *:80>    DocumentRoot "E:/wamp/www/galaxyPHP/"    ServerName  testimmi.com    ServerAlias m.testimmi.com    <Directory "E:/wamp/www/galaxyPHP/">    Allow from all          </Directory>    <IfModule dir_module>       DirectoryIndex  mobile.php index.html index.htm default.php default.htm default.html    </IfModule></VirtualHost><VirtualHost *:80>    DocumentRoot "E:/wamp/www/galaxyPHP/"    ServerName  testimmi.com    ServerAlias www.testimmi.com    <Directory "E:/wamp/www/galaxyPHP/">    Allow from all          </Directory>    <IfModule dir_module>       DirectoryIndex  index.php index.html index.htm default.php default.htm default.html    </IfModule></VirtualHost>

其中DocumentRoot就代表網站工程所在目錄,ServerName代表次層網域,ServerAlias就是別名(允許是完整次層網域(帶www.)或者子網域名稱),

在ThinkPHP工程中,通過這裡配置不同入口檔案index.php 、mobile.php可以便捷區分不同的模組入口,結合.htaccess檔案最終達到可以簡化路由url的目的。

如果httpd-vhost.conf檔案配置不起作用,要注意兩點:

1、Apache設定檔httpd.conf中允許載入http-vhosts.conf模組:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

2、開啟rewrite-module功能;

 

測試環境下,可以配置系統host檔案,添加

192.168.1.122 testimmi.com
192.168.1.122 m.testimmi.com
192.168.1.122 www.testimmi.com

來類比申請到次層網域的情況

 

網站部署頂層網域、次層網域、子網域名稱

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.