Using Rewrite function in Web.config to redirect a url to a subdirectory

Discussion in 'ASP.NET / ASP.NET Core' started by jbm123, Mar 29, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I rewrote the code supplied by nuclearspike in a previous post to redirect a url to a subdirectory in the root of my hosted domain. The placed the Web.config file containing the code (shown below) in the root directory. I purchased a domain pointer for the redirected url (thebitplayers.net).

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.web>
    <rewrite>
    <rules>
    <rule name="thebitplayers_net" stopProcessing="true">
    <match url=".*"/>
    <conditions>
    <add input="{HTTP_HOST}" pattern="^(www.)?thebitplayers.net"/>
    <add input="{PATH_INFO}" pattern="^/BitPlayers/" negate="true"/>
    </conditions>
    <action type="Rewrite" url="\thebitplayers\{R:0}"/>
    </rule>
    </rules>
    </rewrite>
    </system.web>
    </configuration>

    When I try to access any site in my hosted domain containing the Web.config file I get the following HTTP error message (500.19):

    Module IIS Web Core
    Notification Unknown
    Handler Not yet determined
    Error Code 0x80070032
    Config Error The configuration section 'rewrite' cannot be read because it is missing a section declaration
    Config File \\?\E:\web\newportlive\htdocs\web.config
    Requested URL http://www.thebitplayers.net:80/
    Physical Path
    Logon Method Not yet determined
    Logon User Not yet determined

    Any suggestions?
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

  3. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Sorry, I went to look up nuclearspike's post. Change

    <system.web>
    </system.web>

    to

    <system.webServer>
    </system.webServer>

    This is what the URL Rewrite module creates if you follow the instructions in the blog.
     
  4. You may also want to take a look at this URL from Microsoft's IIS site.

    It covers many of the basics and offers some step-by-step instructions including sample code for the URL re-write module.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page