网站部署一级域名、二级域名、子域名
關(guān)于域名介紹:
一般來說,一個(gè)完整的域名用二個(gè)或者二個(gè)以上部分組成,各部分之間用英文的句號“.”開分割。如“www.baidu.com”,其中最后一個(gè)“.”的右邊部分“.com”成為頂級域名(TLD,也成為一級域名,類似還有.cn,.net,.org,.gov,.edu,.tv等等,這里.com.cn其實(shí)是.cn下的二級域名)。任何個(gè)人都可以注冊一個(gè).com域名,其中baidu.com也就是頂級域名.com下的二級域名,baidu.com還可以有image.baidu.com、music.baidu.com的形式,這里的imagemusic可以稱為“子域名”;
二級域名和子域名的Apache配置:
進(jìn)入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就代表網(wǎng)站工程所在目錄,ServerName代表二級域名,ServerAlias就是別名(允許是完整二級域名(帶www.)或者子域名),
在ThinkPHP工程中,通過這里配置不同入口文件index.php 、mobile.php可以便捷區(qū)分不同的模塊入口,結(jié)合.htaccess文件最終達(dá)到可以簡化路由url的目的。
如果httpd-vhost.conf文件配置不起作用,要注意兩點(diǎn):
1、Apache配置文件httpd.conf中允許加載http-vhosts.conf模塊:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
2、開啟rewrite-module功能;
測試環(huán)境下,可以配置系統(tǒng)host文件,添加
192.168.1.122 testimmi.com
192.168.1.122 m.testimmi.com
192.168.1.122 www.testimmi.com
來模擬申請到二級域名的情況
總結(jié)
以上是生活随笔為你收集整理的网站部署一级域名、二级域名、子域名的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 10 个免费高清图片素材下载网站。#免版
- 下一篇: Python3之利用Cookie模拟登录