關於apache配置虛擬主機

2022-08-24 14:57:09 字數 1351 閱讀 6563

最近看了下apache配置虛擬主機,主要有三個步驟

1、在apache中的httpd.conf裡面開啟httpd.vhost模組,也就是把這個模組掛載在httpd.conf中

2、在httpd.vhost裡面寫入

80>documentroot 

"e:/a

"servername a.com

"e:/a

">#options +indexes

order allow,deny

allow

from

all

3、在c盤系統盤裡面找到 host檔案,把 127.0.0.1   a.com寫入檔案裡面,重新啟動apache

關於第二代配置這裡講解下

documentroot "e:/a"servername a.com

這兩行必須,它說明了**目錄跟 **網域名稱位址

而order allow deny則說明先看允許的,在看不允許的,下面的

allow from all 則允許全部,如果想禁止某個 則可以使用 deny 192.168.1.100類似位址

還可以在後面加入

rewriteengine on

第一行說明開啟重寫模組

第二行是重寫的規則  重寫的規則是使用正規表示式  

rewriterule ([a-z]+)/([a-z]+)/(\d+)\.html$ shownew.php?ctr=$1&fn=$2&id=$3

上一行的意思是如果瀏覽器碰到 ([a-z]+)/([a-z]+)/(\d+)\.html$ 這個規則的路徑 如 index/login/2.html

則讓apache去 shownew.php?ctr=index&fn=login&id=2 的動態檔案,也就是偽靜態技術

這裡的正規表示式使用了 子表示式([a-z]+),捕獲,方向引用($1 代表第乙個子表示式)

directoryindex a.txt  這一行說明如果訪問 a.com這個網域名稱,這直接指向 a.txt 這個檔案

errordocument 404   這裡指明了如果出現404則跳轉到  test.html  這裡需要寫全網域名稱,即    如果是/test.html則不能成功跳轉指向。

apache虛擬主機配置

之前已經在csdn上上傳過apache的文件在這裡補充說明一下,apache2.2.x與tomcat或iis或三者之間的虛擬主機配置。介紹一下如何整合其他 web伺服器,如 iis tomcat 等。網上有 n多整合方案講的都不是很清楚 特別是 windows 下的 這裡要特別提示一下,apache...

apache虛擬主機配置

多個網域名稱 伺服器 對應乙個 ip 位址,配置方法為 namevirtualhost 111.22.33.44 servername www.sample.com documentroot www sample servername www.sample2.com documentroot www...

apache配置虛擬主機

namevirtualhost 80 directoryindex default.php index.html index.php index.htm servername www.host1.com servername host1 com documentroot d wamp www1 er...