一、解析二級(jí)域名。
二、將解析的二級(jí)域名綁定主機(jī)。
二、在網(wǎng)站根目錄下創(chuàng)建”.htaccess”文件。即為”htdocs/.htaccess”文件.并寫(xiě)入下列代碼。(如果有多個(gè)域名則依次填寫(xiě))(2個(gè)為例)
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目錄下創(chuàng)建sub文件夾,用于儲(chǔ)存多個(gè)二級(jí)目錄。
即為”htdocs/sub/sub_shop/index.html”.此文件為二級(jí)域名所指向的目錄。