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>

相关文章

文章浏览阅读8.4k次,点赞8次,收藏7次。SourceCodester Onl...
文章浏览阅读3.4k次,点赞46次,收藏51次。本文为大家介绍在...
文章浏览阅读1.1k次。- php是最优秀, 最原生的模板语言, 替代...
文章浏览阅读1.1k次,点赞18次,收藏15次。整理K8s网络相关笔...
文章浏览阅读1.2k次,点赞22次,收藏19次。此网络模型提供了...
文章浏览阅读1.1k次,点赞14次,收藏19次。当我们谈论网络安...