IIS 7 URL rewrite not working

0 Answers 748 Views
Chat General Discussions Label
Ahad
Top achievements
Rank 1
Ahad asked on 10 Apr 2023, 03:52 PM | edited on 10 Apr 2023, 03:52 PM

Need to set friendly URLs for ASP classic web site running on IIS 7 .

There is this rules in my web.config

<rewrite>
        <rules>
            <rule name="chatter">
                <match url="^chatter/default.aspx?article=([0-9]+)" />
                <action type="Rewrite" url="chatter/article{R:1}.aspx" />
                <conditions>
            <add input="{QUERY_STRING}" pattern="^www\.SUB\.DOMAIN\.org$" />
                </conditions>
            </rule>
        </rules>
    </rewrite>

Nothing happens when I apply this rule. Please note there is subdomain included. Any help ?

    It seems like that the condition won't match. It is looking for query string to match the domain. 
    – amit_g
     Sep 7, 2015 at 19:44
  • You simply misunderstood what is URL rewrite so hope you can learn from basic examples. 
    – Lex Li
     Sep 8, 2015 at 1:58
  • and what is the URL rewrite 
Ahad
Top achievements
Rank 1
commented on 11 Apr 2023, 12:12 AM | edited

can i explain IIS URL rewrite is not working for IIS 8
I recently switched from using IIS 7.5 on one pc to using IIS 8 on another. Everything is operating effectively, with the exception of the URL rewriting There is no other error message save the one I received, "HTTP Error 404.0 - Not Found." I've only seen that the website>modules configuration page includes an item for RewriteModule (%SystemRoot%system32inetsrv rewrite.dll), but IIS 8 doesn't have the same module. It didn't work even after I added the same module to IIS 8. If you have any ideas on how to remedy the issue, I would appreciate hearing them. On request, more information might be given.

I hope I was able to communicate myself clearly. 
Rumen
Telerik team
commented on 11 Apr 2023, 11:01 AM

Hi Ahad,

URL rewriting is a technique used to change the URL of a web page. It is often used to make URLs more user-friendly, search engine friendly, or to support legacy URLs. The rules in your web.config file are an example of URL rewriting using the IIS URL Rewrite module.

In your specific case, the rule you have defined is trying to rewrite the URL from chatter/default.aspx?article=([0-9]+) to chatter/article{R:1}.aspx, where {R:1} is the captured group from the regular expression in the match pattern. However, the condition you have defined is looking for a query string that matches the pattern ^www\.SUB\.DOMAIN\.org$, which is not related to the URL being rewritten.

You can try to fix the issue, by removing the condition from the rule, and modifying the match pattern to include the subdomain, like this:

 

<rewrite>
  <rules>
    <rule name="chatter">
      <match url="^chatter/default\.aspx\?article=([0-9]+)" />
      <action type="Rewrite" url="http://www.SUB.DOMAIN.org/chatter/article{R:1}.aspx" />
    </rule>
  </rules>
</rewrite>

This rule should rewrite URLs of the form http://www.SUB.DOMAIN.org/chatter/default.aspx?article=<number> to http://www.SUB.DOMAIN.org/chatter/article<number>.aspx.

Regarding the issue with URL rewriting not working on IIS 8, it is possible that the IIS URL Rewrite module is not installed or configured correctly on the new server. You can try reinstalling the module, or verifying that it is enabled in IIS Manager. Additionally, you can check the IIS logs for more information about the 404 error, which might provide some clues as to what is causing the issue.

Please also be aware that the Telerik UI for ASP.NET AJAX forums are dedicated to discussing issues and features related to the Telerik AJAX product and controls. Therefore, the reported scenario may not be relevant to these forums. We kindly request that you direct such non-Telerik-specific inquiries to the appropriate channels like StackOverflow and Microsoft forums. Thank you for your understanding.

No answers yet. Maybe you can help?

Tags
Chat General Discussions Label
Asked by
Ahad
Top achievements
Rank 1
Share this question
or