2

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!

Abhishekh Gupta
  • 6,206
  • 4
  • 18
  • 46
Shafiq
  • 105
  • 9

1 Answers1

3

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> 
Abhishekh Gupta
  • 6,206
  • 4
  • 18
  • 46
  • Thank you @beginner this gives me the url http://www.domain.com/equipment/flexible/technical/2/applications instead but i think I can still work with this. Thanks! – Shafiq Nov 17 '16 at 15:17
  • As a side note we have I have quite a few different urls that require rewriting, but all take on a similar sturcture of two url paramaters. examples: http://www.domain.com/equipment/flex/technical.cfm?id=2&title=request http://www.domain.com/equipment/aero/technical.cfm?id=2&title=basics http://www.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 ? Thanks again! – Shafiq Nov 17 '16 at 15:30
  • @Shafiq You can manage that by using a single rule by capturing the parent folder of the requested pages i.e., flex, aero... – Abhishekh Gupta Nov 17 '16 at 16:37
  • OK. The parent folder I can grab via coldfusion code. But can you advice on the rewrite rule? Thanks for your help! – Shafiq Nov 17 '16 at 17:03
  • Brill ... Didnt know you could do that. Thanks! – Shafiq Nov 18 '16 at 08:51