I am rewriting the url http://www.tworiverstaines.co.uk to http://www.tworiverstaines.co.uk/TwoRivers/ using this rule:
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^www.tworiverstaines.co.uk$" />
</conditions>
<action type="Rewrite" url="TwoRivers/{PATH_INFO}" />
When the site first loads the rewrite works correctly displaying Default.aspx with all the hyperlinks working correctly including the path to the App_Themes folder etc.
However when you click on the homepage link (or any other) when the Default.aspx (or page requested) loads all the hyperlinks and paths are altered from /Default.aspx to /TwoRivers/Default.aspx so when you click on a hyperlink it is broken as the rewrite rule will take you to www.tworiverstaines.co.uk/TwoRivers/TwoRivers/Default.aspx.
To prevent the 404 error I have added a local rule to rewrite /TwoRivers/TwoRivers/ to /TwoRivers/ however this isn't a good solution as the URL in the browser shows the subfolder and pages become available at /Default.aspx and /TwoRivers/Default.aspx which could present duplicate content issues with search engines.
Does anyone have any idea why this is happening?
The site can be accessed at http://www.tworiverstaines.co.uk
I am displaying the header information at the bottom of each page to display the paths. The web server is running IIS 7 ASP.NET 3.5 SP1.