PHP配置虛擬網域名稱和路由簡化URL路徑

2021-09-01 16:00:25 字數 867 閱讀 6895

apache\conf\httpd.conf目錄中470行,去掉#如下

##    documentroot "專案路徑下\public"

# servername xx.com

#

此時localhost訪問的卻是專案目錄下,還原localhost訪問htdoc

##    documentroot "路徑\htdoc"

# servername localhost

#

c:\windows\system32\drivers\etc\hosts下修改host配置自己的虛擬網域名稱如 xx.com

use think\route;

route::rule('hello','目錄名/控制器名/方法名');

// 是否強制使用路由

'url_route_must' => true

完整的路由的規則應為

route::rule('路由表示式','路由位址','請求型別','路由引數(陣列)','變數規則(陣列)');
請求型別為get,post,delete,put,* ,卻省時預設的請求方式為 *,表示所有請求方式都可請求,這樣並不好,應該明確指定請求的方式。

PHP 配置虛擬網域名稱訪問

本內容分以下幾個步驟 1 首頁我們得找到host檔案 這個檔案在c盤中 windows system32 drivers etc hosts 在該檔案中插入 php view plain copy print?localhost name resolution is handled within d...

php學習 本地配置虛擬網域名稱

整合環境phpstudy apache php5.4 apache配置虛擬網域名稱首先是在httpd conf裡注釋掉 開啟vhost conf serveradmin admin phpstudy.net documentroot 根目錄 servername 網域名稱 options index...

PHP的虛擬網域名稱的配置

第一步 開啟apace的安裝檔案的所在地,到conf目錄下找到htpd.conf,並雙擊開啟。將516行前的 號去掉 第二步 開啟windows資料夾下面的system32下的drivers下面的etc資料夾,在etc檔案下雙擊開啟hosts 我在電腦裡面的檔案位置c windows system3...