locked
Web.Config - URL Rewrite RRS feed

  • Question

  • User-2014164074 posted
    Hello

    I need help.  I am trying to write a multiple URL rewrite rules.  I have this:

    my website is broken down into 4 areas: Pages, News, Articles, Search.  If a user clicks on a page, i.e., mydomain.com/pages/hello then the URL Rewrite would be mydomain.com/htmlpage.aspx?Q=Hello.  If the user clicks on an article. i.e. mydomain.com/article/usa-elections-2020 then the URL Rewrite would be mydomain.com/article.aspx?Q=usa-elections-2020.  If the user clicks on page 2 of News, i.e., i.e. mydomain.com/news/2 then the URL Rewrite would be mydomain.com/news.aspx?P=2.  and so on.  I need the XML code under the web.config file.  I have the following but only the first rule works:

    <httpErrors errorMode="Detailed"></httpErrors>
        <asp scriptErrorSentToBrowser="true"></asp>
        <rewrite>
          <rules>

    <rule name="HTML Page" stopProcessing="true">
              <match url="(.*)$"  ignoreCase="false" />
              <conditions>
                <add input="{URL}" pattern="/pages/(.*)" />
              </conditions>
              <action type="Rewrite" url="htmlpage.aspx?Page={R:1}"  appendQueryString="true" />
    </rule>

    <rule name="Article Page" stopProcessing="true">
              <match url="(.*)$"  ignoreCase="false" />
              <conditions>
                <add input="{URL}" pattern="/articles/(.*)" />
              </conditions>
              <action type="Rewrite" url="article.aspx?Q={R:1}"  appendQueryString="true" />
    </rule>

    </rules>
        </rewrite>

    I hope this makes what I seek clear.  Please send me the exact code that works under GoDaddy Shared Hosting as they are so trouble makers.

    Thanks

    Awny

    Thursday, October 1, 2020 6:30 AM

All replies