IIS 7.5 URL Rewrite question

I need to rewrite:

from: http://mysite.com/subdivisions/subName.html
to:     http://mysite.com/subdivisions/details.cfm?subID=1

I know little to nothing about regex and url rewrites, but here is what I have so far and it fails with a 404.

    <match url="(.*)/(.*)/(.*)\.html$" ignoreCase="false" />
     <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
  <action type="Rewrite" url="/subdivisions/details.cfm?subId={R:1}&amp;subName={R:2}" />

Any help appreciated!
Who is Participating?
Terry WoodsConnect With a Mentor IT GuruCommented:
Sorry, I still think we're missing a key detail. You're wanting:
rewritten to:

Are you wanting the subName in the requested URL to be queried in your database to produce the resulting URL with the subID in? Or is the some way the subID is included in the requested URL?
arnoldConnect With a Mentor Commented:
How do you get from subName.html to details.cfm?subID=1

The above is a direct, if request is for/subdivisions/subName.hml refirection to /subdivisions/details.cfm?subID=1

There is no regex matching needed.

First you should ignore case.
There are many examples search for IIS 7.5 rewrite web.config

You need a regex if your URL has to be reorganized
Http://www.mysite.com/path1/path2/file.html needs to be redirected to http://www.mysite.com/path2/path1/file.html

(.*) match will be set in $1 and any subsequent match will be in the next increment.
Bang-O-MaticAuthor Commented:

Firstly, Thanks for the help I do appreciate it.

I'm trying to rewrite not one, but hundreds of these url's to SES.

What I'm looking for is help in writing the rule that will accomplish this.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Terry WoodsIT GuruCommented:
Where does the value 1 used in the subID in your example come from?
Bang-O-MaticAuthor Commented:
Value 1 and value 2 are both stored in a database table.
Bang-O-MaticAuthor Commented:
Hi and thanks for the help!

Yes the subName will be queried to produce the URL. for instance my first record in the table is subID=1 and subName=Kensington-Place

I guess normally you would have the record pk like "subID" in the URL  ex. http://mysite.com/subdivisions/1/Kensington-Place.html 

but I want to rewrite to

I hope I answered your question.
If the data is in a database, you need to search for IIS rewrite rules using database as source.
Discusses and provides an example on a redirect using data in a database by calling a stored procedure.

Bang-O-MaticAuthor Commented:
I solved it myself using just one variable.

<rule name="subdivisionRewrite">
                    <match url="subdivisions/(.*)\.html$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="/subdivisions/subdetails.cfm?subID={R:1}" appendQueryString="false" />
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.