一、解析二级域名。

二、将解析的二级域名绑定主机。

二、在网站根目录下创建”.htaccess”文件。即为”htdocs/.htaccess”文件.并写入下列代码。(如果有多个域名则依次填写)(2个为例)

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?shop.xxx.com$
RewriteCond %{REQUEST_URI} !^/sub/sub_shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /sub/sub_shop/$1
RewriteCond %{HTTP_HOST} ^(www.)?shop.xxx.com$
RewriteRule ^(/)?$ sub/sub_shop/index.html [L]

RewriteCond %{HTTP_HOST} ^(www.)?video.xxx.com$
RewriteCond %{REQUEST_URI} !^/sub/sub_video/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /sub/sub_video/$1
RewriteCond %{HTTP_HOST} ^(www.)?video.xxx.com$
RewriteRule ^(/)?$ sub/sub_video/index.html [L]

三、在htdocs目录下创建sub文件夹,用于储存多个二级目录。

即为”htdocs/sub/sub_shop/index.html”.此文件为二级域名所指向的目录。

 

感谢博主分享,萌新亲测可用!
--------------------- 
作者:itchuan.net 
来源:CSDN 
原文:https://blog.csdn.net/sinat_37390744/article/details/62051600 
版权声明:本文为博主原创文章,转载请附上博文链接!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐