« Previous Next »

Not Answered Thread: URL Rewrite not working - Displays 404

Last post 03-22-2009 6:18 PM by DanielVL. 10 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (11 items)

Sort Posts:

  • 03-15-2009, 11:54 PM

    • yole79
    • Not Ranked
    • Joined on 07-07-2008, 3:44 AM
    • Posts 5

    URL Rewrite not working - Displays 404

    Hi,

    I have been playing around with the URL Rewrite module in IIS 7 and configured it on my local machine where it is working fine within the hosted application. I have now deployed the website to a test server where it is hosted as a web site only and now im getting an ASP 404 error page, Server Error in '/Reports' Application (which of course does not exist). I have no tried adding an application under the server's Default Web Site and pointed it to the same physical files as the deployed version and the URL Rewrite is working. Is there a trick to get it going under a web site?

    My Rewrite configuration:

    <rewrite>

    <rewriteMaps>

    <rewriteMap name="Reports"/>

    </rewriteMaps>

    <rules>

    <rule name="Reports">

    <match url="^reports/((.+)/)?(.+).aspx"/>

    <action type="Rewrite" url="Report.aspx?report={R:3}&amp;group={R:2}" appendQueryString="false"/>

    </rule> </rules>

    </rewrite>

    I have tried turning on tracing as per http://learn.iis.net/page.aspx/467/using-failed-request-tracing-to-trace-rewrite-rules/ in an attempt to work out this problem, however the logs are not appearing.

    Any help will be greatly appreciated.

    Thanks,
    Dan

  • 03-16-2009, 10:06 AM In reply to

    Re: URL Rewrite not working - Displays 404

    Post the full error and look at the IIS logs to see what it is actually redirecting to, if anything.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 03-16-2009, 6:41 PM In reply to

    • yole79
    • Not Ranked
    • Joined on 07-07-2008, 3:44 AM
    • Posts 5

    Re: URL Rewrite not working - Displays 404

    Hi Jeff,

    I have successfully enabled the tracing for the rewrite module, however neither the IIS logs or trace file have any information relating to the request when it is made.

    The exception is:

    Server Error in '/Reports' Application.

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /Reports/Person/EmployeeReport.aspx

    Thanks,

    Dan

  • 03-17-2009, 11:43 AM In reply to

    Re: URL Rewrite not working - Displays 404

    I am facing similar stuff with my Server:

    Server 2008 / IIS7 / URL Rewriter
    PHP / mySQL and as application Magento (Shopsystem)

    Everything is running fine when I am on the server console using the full qualified name for that application for example http://blahblahblah.domainName.com , but when I try the same from outside, NOT everything works as desired....because:

    404 errors should be redirected to the index.php in the root, but this works only as described when I am working on a console on the server.

    My Guess is that this has to do with the rights, as I have diffrent rights when I am directly on the console of the server, but I am just guessing.. any Ideas around?

    PARTLY SOLVED:
    I went into the IIS7 and opened the 404 Error handlers and hardcoded the path to the index.php in the root of my web. This made the trick, even tho i still dont know, why it worked on the console without this change.

    The Magento is now up and running fine with all features and pages working.
    In the mean time I have also understood that the Magento rewrite rules are just there to prevent access to some directories, because they have read write permissions for the IUSR_xxxxx

    Best wishes

    Tango

  • 03-17-2009, 1:14 PM In reply to

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

    Re: URL Rewrite not working - Displays 404

    Dan, it looks like the rule pattern never matches the requested URL which causes 404. Where is web.config file with rewrite rule located relative to the web site root? Also what is the actual URL you request, including the domain name?

    http://ruslany.net
  • 03-17-2009, 1:19 PM In reply to

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

    Re: URL Rewrite not working - Displays 404

    Andreas, this may be caused by IIS custom errors configuration. Refer to the post "Enable Custom Errors in WordPress" to see how this is solved for WordPress. May be in case of your application the solution can be similar.

    http://ruslany.net
  • 03-17-2009, 5:35 PM In reply to

    • yole79
    • Not Ranked
    • Joined on 07-07-2008, 3:44 AM
    • Posts 5

    Re: URL Rewrite not working - Displays 404

    Hi Ruslany,

    The rewrite rules are in the web config at the root of the web site, say c:\inetpub\mywebsite. The request goes to http://mywebsite/Reports/Person/EmployeeReport.aspx which should then map to http://mywebsite/report.aspx?report=EmployeeReport?group=Person. Just to clarify from my initial post, if i add a an application in IIS 7 under the Default Web Site pointing to the same physical files and make the request http://myserver/mytestsite/Reports/Person/EmployeeReport.aspx all works fine. Also if i point http://mywebsite to an empty folder then add the website as an application under that, the request http://mywebsite/mytestsite/Reports/Person/EmployeeReport.aspx works as expected. Keep in mind that rewrite configuration is now under mytestsite.

    Now i have tested pointing the Default Web Site of the server to mywebsite and the rewrite fails again. So it seems that its not working when being used under a Website rather than an Application. Is there any other configurations that have to be made in these cases?

    Thanks again,

    Dan

  • 03-17-2009, 6:27 PM In reply to

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

    Re: URL Rewrite not working - Displays 404

    From your description everthing looks correct. Having Failed Request trace log would really help figuring this out. Can you enable Failed request tracing for mywebsite, make a request to http://mywebsite/Reports/Person/EmployeeReport.aspx, then go to C:\inetpub\logs\FailedReqLogFiles\W3SVCN, where N is the ID of mywebsite and see if there are any log files there. In the log files look for events that start with URL_REWRITE.

    http://ruslany.net
  • 03-17-2009, 8:13 PM In reply to

    • yole79
    • Not Ranked
    • Joined on 07-07-2008, 3:44 AM
    • Posts 5

    Re: URL Rewrite not working - Displays 404

    I have enabled the trace to log RequestNotifications and Rewrite. Making a request to a physical page causes a trace to be logged, however making the request to the rewrite url fails to log anything. Same deal for the IIS log. Even if i enable tracing of every feature, still nothing gets logged at all when i make that request. It simply shows the exception page as in my previous post.

    Any other thoughts?

    Cheers

  • 03-22-2009, 6:04 PM In reply to

    • yole79
    • Not Ranked
    • Joined on 07-07-2008, 3:44 AM
    • Posts 5

    Re: URL Rewrite not working - Displays 404

    Anyone?

  • 03-22-2009, 6:18 PM In reply to

    • DanielVL
    • Top 75 Contributor
    • Joined on 10-07-2006, 2:00 PM
    • Redmond, WA, USA
    • Posts 109

    Re: URL Rewrite not working - Displays 404

    Hello,

    To be honest with you, if you enabled all the trace areas and you don't get any log at all, you may have missed some step for setting up Failed Request Tracing. Please send me your applicationHost.config file and the web.config file for your application as private message. I can take a deeper look.

    Thanks.

    Daniel Vasquez Lopez
    URL Rewrite Engine Developer
Page 1 of 1 (11 items)
Microsoft Communities