views:

43

answers:

1

Hi.

I have installed the URLRewriter on my server, and it works fine, but I have a rather big problem.

Relative links in hyperlinks, CSS-links, images etc. doesn't work when I have URLs with more than one substring.

E.g. (sorry, no http:// in front, as I do not have enough reputation):

dkbyg.strandweb.dk/Leje-og-udlejning-arbejdskraft leads to the path dkbyg.strandweb.dk/Workers.aspx and works just fine.

But

dkbyg.strandweb.dk/Leje-og-udlejning-arbejdskraft/Midtjylland leads to dkbyg.strandweb.dk/Workers.aspx?Region=Midtjylland using this line in the Web.config:

<rewrite url="~/Leje-og-udlejning-arbejdskraft/(.+)" to="~/Workers.aspx?Region=$1"/>

It rewrites just fine, but my relative links doesn't work anymore. CSS, Images, links and so on thinks my root is now http://dkbyg.strandweb.dk/Leje-og-udlejning-arbejdskraft, which of course doesn't exist.

Can't this be fixed? All my links are correctly set using the ~/, like this:

<asp:HyperLink ID="HyperLink3" CssClass="black_text" NavigateUrl="~/Forgot-Password"
                        runat="server">I have forgotten my password</asp:HyperLink>
A: 

For now, my solution was to add the following in my -tag:

<base href="http://dkbyg.strandweb.dk/"&gt;

However, I hope you have some better suggestions, as I constantly move the project between localhost and online server, and have to correct it each time.

Andreas Strandfelt