Solved

Need help with URL ReWrite in IIS 8.5

Posted on 2014-09-10
4
197 Views
Last Modified: 2014-09-17
I am new to URL ReWrite. I am trying to create a rule to change
/Parts.aspx?pn=3299W-1-103
to
/Items.aspx?pn=3299W-1-103
With after "pn=" needing to be captured and applied to the rewritten URL.

I started with creating a blank rule. In the Match URL, under pattern I have "^/Parts.aspx?id=([_0-9a-z-]+)" but when I go to Test Pattern, it says the input data does not match the pattern.

If in the pattern I change it to "^/Parts.aspx([_0-9a-z-]+)" and test with "/Parts.aspx3299W-1-103" it works, but I need the "?pn=" to be there.

Any ideas or help?
0
Comment
Question by:jst3751
  • 3
4 Comments
 
LVL 28

Expert Comment

by:becraig
Comment Utility
Here you go:

<add input="{QUERY_STRING}" pattern="(?:^|&)id=([0-9]+)(?:&|$)" /> - this condition checks if the query string contains a parameter id that has a numeric value. The actual value is captured in a condition back-reference. Note that this pattern will work even if there are other parameters on the query string.

More info on how to make this work for you:
http://www.iis.net/learn/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module
0
 
LVL 1

Author Comment

by:jst3751
Comment Utility
For the testing of the pattern, turns out I needed to use the escape character before the ?, so the pattern is actually

^/Parts.aspx\?pn=([_0-9a-z-]+)

So now testing the pattern works.

However, testing the actual website, I keep getting a 404 page not found and looking at the IIS log, it appears that the rewrite rule is not even being used.
0
 
LVL 1

Accepted Solution

by:
jst3751 earned 0 total points
Comment Utility
OK, got this to work finally.

SIMPLIFY

On the rule for pattern to match, used

/parts.aspx

rewrite to

/items.aspx

and it works as expected.
0
 
LVL 1

Author Closing Comment

by:jst3751
Comment Utility
Sometimes try not to overthink the problem and simplify it and go with the basics.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now