您好,欢迎访问一九零五行业门户网

网站部署一级域名、二级域名、子域名

关于域名介绍:
一般来说,一个完整的域名用二个或者二个以上部分组成,各部分之间用英文的句号“.”开分割。如“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
来模拟申请到二级域名的情况
其它类似信息

推荐信息