lundi 18 septembre 2017

Create friendly url IIS

I have a original URL which looks likes this:

http://ift.tt/2ykr4jP's

I created a rule within the IIS manager, which rewrites above to

http://ift.tt/2y9vNUu's/

This works fine.


However, when the original URL is like this:

http://ift.tt/2ykr4jP's/birthday/2016

It gets correctly rewritten to:

http://ift.tt/2ylSkyG's/birthday/2016/

But the page results in a error 404. How can I let the server interpret &path=Video's/birthday/2016 as a query value rather than a remote folder path?

The problem is caused by the / character inside the query string.

Web.config

<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
  <match url="^$" />
  <conditions>
    <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
    <add input="{QUERY_STRING}" pattern="^page=([^=&amp;]+)&amp;path=([^=&amp;]+)$" />
  </conditions>
  <action type="Redirect" url="{C:1}/{C:2}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
  <match url="^([^/]+)/([^/]+)/?$" />
  <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  </conditions>
  <action type="Rewrite" url="?page={R:1}&amp;path={R:2}" />
</rule>

Aucun commentaire:

Enregistrer un commentaire