views:

564

answers:

2

Hi

I'm setting up some rewrite paths using the IIS 7 rewrite module.

I just can't get my head around this one.

My friendly URL should look like this:
http://localhost/5f3ff4a5-1fb4-4470-904f-bd55e4fabc5d/marketing_performance/dashboard/

And rewrite to this:
http://localhost/marketing_performance/dashboard.aspx?account=5f3ff4a5-1fb4-4470-904f-bd55e4fabc5d

A: 

I actually nailed it:
Pattern: ^([^/]+)/([^/]+)/([^/]+)/?$
Rewrite: {R:2}/{R:3}.aspx?account={R:1}

But when I have a page with a normal HTML link with href="../../test.aspx" it fails, with this error: Cannot use a leading .. to exit above the top directory. So I guess i have to refactor all my links such as this.

MartinHN
+1  A: 

Just add two conditions to this rule to check if the requested URL is not a file and is not a directory. That way your normal html links will continue to work:

<conditions>
<add input="{REQUEST_FILENAME}" matchType="isDirectory" negate="true" /> <add input="{REQUEST_FINENAME}" matchType="isFile" negate="true" /> </conditions>