WAMPSERVER伺服器多站點配置
step1: wamp\bin\apache\apache2.4.9\conf\https.conf
在https.conf檔案中解除一下程式碼的註釋,即去掉前面的#:
LoadModule rewrite_module modules/mod_rewrite.so
提供在執行中基於規則的地址重寫的支援
mod_rewrite是一個基於一定規則的實時重寫URL請求的引擎。此模組可以操作URL的所有部分,在伺服器級的(httpd.conf)和目錄級的(.htaccess)配置都有效。
Include conf/extra/httpd-vhosts.conf
這樣就開啟了httpd-vhosts虛擬主機檔案。這時候重啟wamp環境,無法開啟localhost,需要在httpd- vhosts.conf配置一下。
step2:wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf
刪除/註釋原有的程式碼新增以下程式碼:
<VirtualHost *:80> DocumentRoot "D:\\WorkFile\\www\\public" ServerName php.do ServerAlias php.do <Directory "D:\\WorkFile\\www\\public"> Options FollowSymLinks AllowOverride All Require all granted DirectoryIndex index.php default.php index.html </Directory> </VirtualHost>
ServerName: 用來設定伺服器用於辨識自己的主機名和埠號。主要用於建立重定向URL。
ServerAlias: 用來設定伺服器用於辨識自己的別名和埠號。主要用於建立重定向URL。
DocumentRoot: 語法:DocumentRoot directory-path 用來設定httpd提供服務的目錄。即你所在專案入口處的資料夾。
DirectoryIndex index.html index.htm index.php 設定訪問目錄後進入的預設檔案
Options FollowSymLinks 該目錄中,伺服器將跟蹤符號連結。注意,即使伺服器跟蹤符號連結,它也不會改變用來匹配不同區域的路徑名,如果在<Local>;標記內設定,該選項會被忽略
AllowOverride All 在 AllowOverride 設定為 None 時, .htaccess 檔案將被完全忽略。當此指令設定為 All 時,所有具有 ".htaccess" 作用域的指令都允許出現在 .htaccess 檔案中。
Require all granted 允許所有請求訪問資源