Php:使用web.config重写URL
发布时间:2020-12-13 15:55:24 所属栏目:PHP教程 来源:网络整理
导读:这是我的第一个 PHP应用程序,我在本网站使用.html和.php页面.如果用户浏览mysite.com/users/?abc123,它会通过Ajax在普通的html页面mysite.com/users/index.html上成功加载id为’abc123’的用户的详细信息.现在,我的任务是删除?从URL中,如果用户浏览mysite.c
这是我的第一个
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但这似乎没有用,我收到了:
<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重写(以保持简单) 解决方法
这应该有效
<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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |