Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need regex for IIS URL rewrite

Posted on 2011-10-11
4
Medium Priority
?
266 Views
Last Modified: 2012-08-13
I have to write a URL re-write using the IIS7 url rewrite tool.

My original URL looks like /events/A-New-Site-OOO.htm?promotion=3036
I need the to be able to create the back references for each part...

$1 = events
$2 = A-New-Site-OOO
$3 = promotion=3036

$2 should be able to handle hyphens
$3 should be everything after the ? or the original query string
0
Comment
Question by:mackaboogie
4 Comments
 
LVL 4

Author Comment

by:mackaboogie
ID: 36951660
Just a starter...
I started with something like this:
^([-A-Za-z0-9]+)/([^/]+)(\.[^.]*$)$

What it gives me is the following..

$1 = events
$2 = A-New-Site-OOO
$3 = .htm?promotion=3036

so I am pretty close...
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 36951716
Try:
^([-A-Za-z0-9]+)/([^/]+)[^/]*\?(.*)$
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 36951927
Here you go:
^\/?([^\/]+)\/([^.]+)\.[^?]+\?(.*)$

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36951938
What if you did:

([^/]+)/([^.]+)[^?]+\?(.*)

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
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 Month20 days, 19 hours left to enroll

810 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