Shafiq
Shafiq

Reputation: 105

IIS Rewrite - Creating SEO Friendly URL

Using IIS v8 and trying to create some SEO Friendly URL's

Current URL is as follows:

http://www.domain.com/equipment/flexible/technical.cfm?id=2&title=applications

Trying to create:

http://www.domain.com/equipment/flexible/2/applications

I have the following rule added within web.config - but doesnt seem to be working.

<rule name="Product Technical Details">
  <match url="^/equipment/flexible/technical.cfm?([0-9]+)/([_0-9a-z-]+)" />
  <action type="Rewrite" url="/equipment/flexible/technical.cfm?id={R:1}&amp;title={R:2}" />
</rule> 

Any ideas?

Thanks!

Upvotes: 2

Views: 2313

Answers (1)

Abhishekh Gupta
Abhishekh Gupta

Reputation: 6236

Your incoming URL is in the format:

http://www.domain.com/equipment/flexible/{id}/{title}

So, you can modify the rule like this:

<rule name="Product Technical Details">
  <match url="^equipment/flexible/technical/([0-9]+)/([_0-9a-z-]+)" />
  <action type="Rewrite" url="equipment/flexible/technical.cfm?id={R:1}&amp;title={R:2}" />
</rule> 

Edit 1:

domain.com/equipment/flex/technical.cfm?id=2&title=request domain.com/equipment/aero/technical.cfm?id=2&title=basics domain.com/equipment/bulk/technical.cfm?id=2&title=general

Would I have to create individual rules for each of the above urls? or is it possible to create a single rule for all off the above ?

You can update the rule like this:

<rule name="Product Technical Details">
  <match url="^equipment/(flex|aero|bulk)/technical/([0-9]+)/([_0-9a-z-]+)" />
  <action type="Rewrite" url="equipment/{R:1}/technical.cfm?id={R:2}&amp;title={R:3}" />
</rule> 

Upvotes: 3

Related Questions