Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IIS 7.5 URL Rewrite question

Posted on 2013-10-23
8
Medium Priority
?
626 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 80

Assisted Solution

by:arnold
arnold earned 1000 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 1000 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 80

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
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…
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

971 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