微擎应用地址伪静态转换部署

作者: unvs 分类: PHP 发布时间: 2019-06-20 12:01 ė19,413 views 6没有评论

微擎应用站点根目录新建.htaccess文件,或服务器站点自带伪静态环境配置,自己需要编写好规则。
下面是IIS规则示例,如下:

RewriteRule /water_api[/]([^/]+)$ /app/lh_water_api.php?do=$1
RewriteRule /api[/]([^/]+)[/]([^/]+)$ /app/api.php?do=$1&type=$2
RewriteRule /api[/]([^/]+)[/]([^/]+)[/]([0-9]+)$ /app/api.php?do=$1&type=$2&p=$3

数字变量使用([0-9]+)
字符串变量使用([^/]+)

访问http://blog.unvs.cn/api/index等同于http://blog.unvs.cn/app/api.php?do=index
访问http://blog.unvs.cn/api/index/detail等同于http://blog.unvs.cn/app/api.php?do=index&type=detail
访问http://blog.unvs.cn/api/index/detail/2等同于http://blog.unvs.cn/app/api.php?do=index&type=detail&p=2

其他服务器文件配置,参考下图:

weiqing-weijingtai

 

07.10补充windows2008+IIS7、IIS7.5的微擎伪静态自定义规则,一般站点根目录下有个web.config文件,没有则新建。
内容如下:

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”index” stopProcessing=”true”>
<match url=”index.html$” ignoreCase=”false” />
<action type=”Rewrite” url=”index.php” appendQueryString=”false” />
</rule>
<rule name=”1″ stopProcessing=”true”>
<match url=”api[/]([^/]+)$” ignoreCase=”false” />
<action type=”Rewrite” url=”app/api.php?do={R:1}” appendQueryString=”false” />
</rule>
<rule name=”2″ stopProcessing=”true”>
<match url=”api[/]([^/]+)[/]([^/]+)$” ignoreCase=”false” />
<action type=”Rewrite” url=”app/api.php?do={R:1}&amp;type={R:2}” appendQueryString=”false” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

本博文章基本上属于原创或收集整理,都是心血结晶。
欢迎转载分享,转载请注明出处,谢谢!
本文地址:微擎应用地址伪静态转换部署

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Ɣ回顶部