« Previous Next »

Thread: URL Rewrite module not working, even with templates

Last post 07-14-2009 4:25 AM by mr baldman. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 07-13-2009, 10:53 AM

    URL Rewrite module not working, even with templates

    I cannot get the URL rewriting module to work on my local PC (vista x86)

    i set up a new rule using the 'user friendly url' template.

    a picture rather than 1000 words....



    so now that is setup if i request 'localhost/iisrewriteurl/content/5 i should see my content.aspx page.

    and the settings page, which i have not changed in any way...

     

     

    nope...

    Error Summary HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
    Detailed Error Information
    Module IIS Web Core
    Notification MapRequestHandler
    Handler StaticFile
    Error Code 0x80070002
    Requested URL IISRewriteURL/content/5/


    When i go back into the rule itself and test the patterns that IIS made for me, they do not work..(see attached picture)



    I have tried adding a wildcard script map under the handler mappings section but this makes no difference.

    Has anyone seen this type of behaviour before? Or am i missing something very simple?

  • 07-13-2009, 2:07 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: URL Rewrite module not working, even with templates

    Where is the web.config file with the rewrite rule located? Is it in the site's root folder or in the IISRewriteURL directory?

    http://ruslany.net
  • 07-13-2009, 5:41 PM In reply to

    Re: URL Rewrite module not working, even with templates

    the web.config with the rewrite rule is located in the root of the IISRewriteURL asp.net 3.5 web application on my pc.

     the rewrite rule here is taken from the system.webserver section of that file...

     

     <rewrite>
                <rules>
                    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                        <match url="^iisrewriteurl/content\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" />
                            <add input="{QUERY_STRING}" pattern="^id=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="iisrewriteurl/content/{C:1}" appendQueryString="false" redirectType="Permanent" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                        <match url="^iisrewriteurl/content/([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="iisrewriteurl/content.aspx?id={R:1}" />
                    </rule>
                </rules>
            </rewrite>

     

    also, here is the  wildcard script map i added via the handler mappings section (which made no difference)...

     

     <add name="Wildcard Map for Rewrites" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness32" />

  • 07-13-2009, 5:47 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Re: URL Rewrite module not working, even with templates

    You should either place these rules to the root folder of your web site, or, if you want to leave them in the IISRewriteURL folder, then change the pattern and substitution URLs not to start with iisrewriteurl. The rules are applied on a path, which is relative to the location of the web.config file, so if you have rules in the IISRewriteURL folder, then they will be evaluated agains the path that is after "IISRewriteURL/".

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

    http://ruslany.net
  • 07-14-2009, 4:25 AM In reply to

    Re: URL Rewrite module not working, even with templates

    Thank you very much for your help, this has solved my problem.

Page 1 of 1 (5 items)
Microsoft Communities