Problem to rewrite an old URL to a new one in IIS manager and web.config file

I’m here in last resort. So here is my problem,
At work my boss asked me to rewrite an URL to be more user friendly.

The old pattern is this one: https://{hostServer}/SiteName/index.html

The new one should be this one: https://maps.swcs.be

But i looked in the doc of IIS, looked in here for some more informations etc…

I learned, it’s done in the web.config file at the root of the repo “wwwroot” So I wrote my rule in there

here it is

<system.webServer>      
  <rule name="redirection d'url">
    <match url=".*"/>
      <conditions>
        <add input="{https://maps.swcs.be}" type="Pattern" pattern="Ëxpertises[0-9]index.html">
      </conditions>
    <action type="Rewrite" url="https://maps.swcs.be" />
  </rule>
</system.webServer>

I tried the <action type="Redirect" ...> too and other stuff but it’s the only one that returned something… the IISstart.htm file

I’m pretty new to URL redirection, if one of you could enligthen me that would be awesome

Thanks in advance

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

First of all, I highly recommend that you read the documentation provided by lex li in detail, which can help you fully understand how to use url rewrite.

Secondly, I want to know your initial url and rewritten url, you don’t have to show the correct url, just an example. Such as initial url is http://example.com/aaa/bbb/ccc/index and rewritten url is http://example.com/index

So I assume your initial url is https://{hostServer}/SiteName/index.html and rewritten url is https://maps.swcs.be.
Problem to rewrite an old URL to a new one in IIS manager and web.config file
Problem to rewrite an old URL to a new one in IIS manager and web.config file

This rule will match the uri, if the uri is /SiteName/index.html, it will redirect to https://maps.swcs.be. You can also change antion type to rewrite. If you choose rewirte, nothing will happen when you check url in browser. But redirect will make the url change to new one in browser.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x