【发布时间】:2015-06-27 05:45:00
【问题描述】:
这是我的第一个 PHP 应用程序,我在这个网站上同时使用了 .html 和 .php 页面。如果用户浏览 mysite.com/users/?abc123,它会成功地在纯 html 页面 mysite.com/users/ 上加载 id 为 'abc123' 的用户的详细信息index.html 通过 Ajax。现在,我的任务是从 URL 中删除 ?,这样如果用户浏览 mysite.com/users/abc123,那么 mysite.com/users/index.html?abc123 应该成功地提供细节。
我遵循this link 并将此规则添加到我的 web.config 中,但这似乎不起作用,我收到了:
错误:HTTP 错误 404.0 - 未找到
<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 服务
【问题讨论】:
-
你安装了 iis url rewrite 吗? iis.net/downloads/microsoft/url-rewrite
标签: php html .htaccess iis url-rewriting