Php:使用web.config重写URL

这是我的第一个 PHP应用程序,我在本网站使用.html和.PHP页面.如果用户浏览mysite.com/users/?abc123,它会通过Ajax在普通的html页面mysite.com/users/index.html上成功加载id为’abc123’的用户的详细信息.现在,我的任务是删除?从URL中,如果用户浏览mysite.com/users/abc123,则mysite.com/users/index.html?abc123应该成功提供详细信息.

我跟着this link并将此规则添加到我的web.config但这似乎没有用,我收到了:

Error: HTTP Error 404.0 – Not Found

<rule name="Remove question mark" patternSyntax="Wildcard" stopProcessing="true">
  <match url="*" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^users/(.*)$" />
  </conditions>
  <action type="Redirect" url="users/?{R:0}" redirectType="Permanent" />
</rule>

请帮助我解决以下问题:

>我只能使用web.config进行URL重写(以保持简单)
>我要重写URL的页面是.HTML而不是.PHP(如果重要的话)
>我在IIS 8中本地测试我的PHP站点,配置为PHP服务

解决方法

这应该有效

<rule name="Remove question mark" stopProcessing="true">
  <match url="^/?users/([^/]+)$" ignoreCase="true" />
  <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  </conditions>
  <action type="Rewrite" url="/users/index.html?{R:1}" />
</rule>

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...