W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
ApiAdmin的URL模式使用兼容模式,當然為了更好的使用API,我們也加入Web服務器重寫規(guī)則。
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
}
//網(wǎng)站跟目錄加入.htaccess文件就可以,配置如下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [L]
當我們訪問:http://localhost/admin/
的時候,經(jīng)過重寫我們訪問的其實是http://localhost/index.php?s=/admin
,再經(jīng)過ThinkPHP默認類和函數(shù)的賦值,我們訪問的是http://localhost/index.php?s=/Admin/Index/index
當我們訪問:http://localhost/api/{hash}
的時候,經(jīng)過重寫我們訪問的其實是http://localhost/index.php?s=/api/{hash}
,再經(jīng)過我們的路由配置,我們訪問的其實是:http://localhost/index.php?s=/Home/Api/index/hash/{hash}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: