Reputation: 6241
This my first PHP application, I am using both .html and .php pages in this website. If user browses mysite.com/users/?abc123, it successfully loads details of user with id 'abc123' on plain html page mysite.com/users/index.html via Ajax. Now, I am tasked to remove ?
from the URL so that if user browses mysite.com/users/abc123, then mysite.com/users/index.html?abc123 should serve the details successfully.
I followed this link and added this rule to my web.config but that didn't seem to work and I received:
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>
Please assist me with following concerns in mind:
Upvotes: 4
Views: 2218
Reputation: 19026
This should be working
<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>
Upvotes: 1