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
Solved

Need help with URL ReWrite in IIS 8.5

Posted on 2014-09-10
4
207 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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