框架中写的很简单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