Php: rewrite url using web.config

This is my first PHP application, I use the .html and .php pages on this website. If the user browses mysite.com/users/?abc123, he successfully loads the user data with the identifier " abc123 " on a simple html page mysite.com/users/index.html via Ajax. Now I need to remove it ?from the URL so that if the user browses mysite.com/users/abc123 , then mysite.com/users/index.html?abc123 should successfully serve the data.

I followed this link and added this rule to my web.config, but this did not seem to work, and I got:

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 not.PHP( )
  • PHP IIS 8, PHP
+4
1

<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>
+1

All Articles