IIS 7 URL Redirect based on URL path

I have a WCF Web Service hosted inside a ASP.NET 4 environment (IIS 7.5 on Windows 7), and I would like to use URL Rewriting / Redirection. The reason I need to do this is because I can't change some mobile device code to just insert the parameter.

Here is the URL I want:


The real URL is:


Notice how I want to remove theOrganization and appended it to the Query string for redirection.

<rule name="test" stopProcessing="true">
    <match url="(.+\.?)/(.+)/RequestService.svc/(.+)" />
    <action type="Redirect" url="{R:1}/RequestService.svc/{R:3}?organization={R:2}"
    redirectType="Permanent" />

I know it's a little odd of a rule to write. Thinks i have my regular expression correct for matching. I run the expression in the URL Rewrite tester in IIS Manager, and it seems like it's matching what I want. Also, I do have IIS URL Rewrite installed, and I made a simple rule up and it worked.

However, when I try it using a browser, it failed to redirect and results in a 404. I was hoping a IIS Rewrite expert could chime in, as I am fairly new at it.



I tested your rule on a test server with iis 7.5 and url rewrite 2.0 and the rule is working, but your regex matches both your wanted url and the real url.

So you end up with a double redirect

I think you want your pattern something like this


Hope this helps.

Need Your Help

CSS first-child

css css-selectors

Is it safe to use CSS pseudo class first-child with regards to browser support and the like?

SQL - Pass Table to a UDF in a Select

sql sql-server sql-server-2008 parameters user-defined-functions

I have a UDF that takes a table as a parameter (a 2 column table) and outputs a string, much like this article. I have a table that I want to apply the UDF over multiple columns like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.