PhalApi框架中的Url重写

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

相关文章
相关标签/搜索