网站部署一级域名、二级域名、子域名
2016-09-22 11:55
417 查看
关于域名介绍:
一般来说,一个完整的域名用二个或者二个以上部分组成,各部分之间用英文的句号“.”开分割。如“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,添加如下配置:
其中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
来模拟申请到二级域名的情况
一般来说,一个完整的域名用二个或者二个以上部分组成,各部分之间用英文的句号“.”开分割。如“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
来模拟申请到二级域名的情况
相关文章推荐
- 一级域名,二级域名,父域名,子域名之间的联系
- 为你的域名添加子域名(二级域名)并绑定网站
- •搭建LAMP环境及快速部署双网站并实现基于域名的虚拟主机
- 一个云主机解析二级域名及部署网站
- Tomcat中部署网站和绑定域名
- 网站二级域名与一级目录的选择
- 我的网站之旅 (二)域名申请,备案,空间申请,部署
- Nginx实现ssl一级、二级域名证书部署并用https访问代理转发服务器
- 一级域名 二级域名,三级域名概念 -- linux内核
- 网站部署和域名解析域名直接访问开发的网页
- dedecms 关于二级域名和一级域名切换
- 网站部署和域名解析域名直接访问开发的网页
- thinkphp自动跳到首页 --开启域名部署/子域名部署/泛域名部署/IP访问部署
- 关于www和一级域名、二级域名的认识误区
- apache实现部署多个网站(一个ip部署多域名)的方法详解
- 网站主机、域名购买和部署的方法
- thinkphp开启域名部署/子域名部署/泛域名部署/IP访问部署
- 阿里云网站部署(三):子域名解析
- 二级域名和一级域名的区别