views:

275

answers:

1

I am rewriting the url http://www.tworiverstaines.co.uk to http://www.tworiverstaines.co.uk/TwoRivers/

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.

A: 

This is because of your action attribute in your form tag. Do you rewrite that form tag also?

On the Page http://www.tworiverstaines.co.uk/Default.aspx you action attribute contains

<form name="aspnetForm" method="post" action="TwoRivers/Default.aspx" id="aspnetForm">

if not, here is a solution:

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

go down to "Handling ASP.NET PostBacks with URL Rewriting"

Arthur
Thanks for your help Arthur I have implemented above but this has not corrected the problem.If you navigate to http://www.tworiverstaines.co.uk/The action path is action="/TwoRivers/default.aspx"All of the links and paths to resources are correct i.e. they do not contain "/TwoRivers/" only the action url contains this.If you navigate to http://www.tworiverstaines.co.uk/Default.aspxThe action path is action="/Default.aspx"All paths are incorrect and they do contain "/TwoRivers/".Any ideas?ThanksDan
McDotNet
How did you implement URL rewrite? What's about the Parameter "rebaseURL"?
Arthur
looks like your ControlAdapter is not registered. Did you doublechecked you App_Browsers/Form.browser file?
Arthur
Form.browser exists in the App_Browsers folder and is preventing the Action path from being rewritten when the url points to a file.If you visit the site at tworiverstaines.co.uk you can see what happens by repetadely clicking home.I think it is my rule that is causing the issue this my latest effort:
McDotNet
<rule name="tworiverstaines.co.uk" stopProcessing="false"><match url="(.*)" /><conditions logicalGrouping="MatchAll"><add input="{URL}" negate="true" pattern="^www.tworiverstaines.co.uk/TwoRivers/.*$" /><add input="{HTTP_HOST}" pattern="^www.tworiverstaines.co.uk$" /></conditions><action type="Rewrite" url="TwoRivers/{PATH_INFO}" /></rule>Every time it execute it adds another "/TwoRivers/" to the path and I don't know how to prevent this?Really appreciate your help!
McDotNet