Solved

IIS 7.5 URL Rewrite question

Posted on 2013-10-23
8
616 Views
Last Modified: 2013-11-05
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.

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

Any help appreciated!
0
Comment
Question by:Bang-O-Matic
  • 4
  • 2
  • 2
8 Comments
 
LVL 77

Assisted Solution

by:arnold
arnold earned 250 total points
ID: 39596290
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.
0
 

Author Comment

by:Bang-O-Matic
ID: 39600963
Hi,

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.
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 39601220
Where does the value 1 used in the subID in your example come from?
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:Bang-O-Matic
ID: 39601235
Value 1 and value 2 are both stored in a database table.
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 250 total points
ID: 39601246
Sorry, I still think we're missing a key detail. You're wanting:
http://mysite.com/subdivisions/subName.html
rewritten to:
http://mysite.com/subdivisions/details.cfm?subID=1

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?
0
 

Author Comment

by:Bang-O-Matic
ID: 39601403
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
http://mysite.com/subdivisions/Kensington-Place.html

I hope I answered your question.
0
 
LVL 77

Expert Comment

by:arnold
ID: 39602208
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.

http://forums.iis.net/t/1187769.aspx
0
 

Author Comment

by:Bang-O-Matic
ID: 39615701
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" />
                </rule>
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question