Take the 2-minute tour ×

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):

website.com/Leje-og-udlejning-arbejdskraft leads to the path website.com/Workers.aspx and works just fine.


website.com/Leje-og-udlejning-arbejdskraft/Midtjylland leads to website.com/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://website.com/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>
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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

<base href="http://website.com/">

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.

share|improve this answer
add comment

Your Answer


