Solved

Need help with URL ReWrite in IIS 8.5

Posted on 2014-09-10
4
216 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
[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
  • 3
4 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40315986
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
ID: 40319760
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
ID: 40320304
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
ID: 40327547
Sometimes try not to overthink the problem and simplify it and go with the basics.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 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