htaccess實現一臺虛擬主機多個獨立域名網站

若是你的主機有1G的空間,能夠綁定20個域名,只用來放一個網站會不會太浪費啦,那是確定很浪費的。接下來咱們來看看怎麼經過htaccess,讓不一樣域名綁定不一樣子目錄,從而實現同一個主機創建多個獨立網站。javascript

咱們使用.htaccess寫入特定規則,就能夠一個空間放多個網站,讓不一樣域名進入綁定不一樣的文件夾:php

RewriteEngine On
RewriteBase /
DirectoryIndex index.php index.html index.htm
RewriteCond %{HTTP_HOST} ^(www\.)?help\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/help/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ help/$1
RewriteCond %{HTTP_HOST} ^www.help.com$
RewriteRule ^(/)?$ help/index.html [L]

這樣咱們就已經把www.help.com這個域名綁定到了help這個子目錄上面,至關於help就是一個獨立域名主機服務器。html


而後用index.html實現域名跳轉java

<script language="javascript" type="text/javascript">
window.location="http://endv.cn";;
</script>
相關文章
相關標籤/搜索