Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IIS 7.5 URL Rewrite question

Posted on 2013-10-23
8
Medium Priority
?
621 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 79

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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 79

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
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…
Suggested Courses

715 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