Solved

IIS 7.5 URL Rewrite question

Posted on 2013-10-23
8
612 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with a redirect in web.config file 8 45
More Than One Website On Same DMZ Server 3 75
WebSite Direction 1 42
parse a file and get data out 11 49
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…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
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…

832 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