框架中寫的很簡單php
除了要在./config/sys.php修改enable_uri_match配置爲true外,還須要同步進行Rewrite規則配置,以便讓你的服務在未找到文件時把請求轉發給index.php處理。 他這裏只講了
Nginx
的配置。那麼在Apache
中是如何配置的呢?api
找到config/sys.php
這個文件,把裏面的enable_uri_match
設置爲true
,開啓路由匹配規則瀏覽器
在public
中建立一個.htaccess
文件,這個在Thinkphp
是有的,可是在PhalApi
框架中默認是沒有的,須要本身建立。bash
複製如下代碼框架
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.php)/((?s).*)$ $1?_url=/$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
複製代碼
打開瀏覽器中的地址http://dev.phalapi.net:4008/App/Hello/World
,即可以正常顯示了url