Avatar of Wayne Barron
Wayne Barron
Flag for United States of America asked on

IIS 10 - URL Rewrite Rule for Search Query, not working?

Hello, All.
(The development is done in ASP Classic (VB), in case I need to do something within the code.)

In the website, our search string is displayed as such.
Main.asp?Type=Results&Submit=Search&Term=KISS&Cat=3

Our URL Rewrite is this.

Pattern: Search/([_0-9a-z-(-)-,-]+)/([_0-9a-z-(-)-,-]+)
Rewrite URL: Main.asp?Type=Results&Submit=Search&Term={R:1}&Cat={R:2}

Screenshot of the RULE
URLRewrite
How can I make the Search Query work, so that when you click search, it rewrites the URL to this?

Search/KISS/3

Thanks.
Wayne
* iis10Microsoft IIS Web Server* URL Rewrite Rules

Avatar of undefined
Last Comment
Wayne Barron

8/22/2022 - Mon
Ryan Chong

your URL Rewrite rule worked well for me.

what's the exact issue you're facing right now?

so that when you click search, it rewrites the URL to this?

if you mean to change form posting action URL based on user's inputs?
Wayne Barron

ASKER

When I click search, the URL does not get re-written.
It stays with the same URL


Main.asp?Type=Results&Submit=Search&Term=KISS&Cat=3



Wayne Barron

ASKER

Here is the search box.


<form action="//192.168.2.12/Main.asp">
<input type="hidden" name="Type" value="Results">
<table style="text-align:left; vertical-align:top;">
<tbody><tr>
  <td style="border:1px #000000 dotted; font-size:12px;">Search<br />
  <input type="submit" name="Submit" value="Search" tabindex="3">
<input name="Term" type="text" tabindex="1" width="200" value="KISS" onBlur="javascript:if (this.value == '') this.value = 'Search';" onFocus="javascript:if (this.value == 'Search') this.value='';">
<br />
<select class="FormUnits" name="Cat" tabindex="2">
<option value="3">Artist</option>
</select>
</td></tr>
</tbody></table>
</form>

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Ryan Chong

When I click search, the URL does not get re-written.
It stays with the same URL


    Main.asp?Type=Results&Submit=Search&Term=KISS&Cat=3

I think you need to edit the HTML instead. Can you share us the source code of your form's action? or click event ?
Wayne Barron

ASKER

Well, I do not like how the new CODE block works on EE.
It messed everything up, which is the reason for posting the code the way I just had to do.

ASKER CERTIFIED SOLUTION
Ryan Chong

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Wayne Barron

ASKER

As always, Ryan you are the best, my friend.
Have a-Rockin' week.

Wayne

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ryan Chong

Cool, glad it worked = )
Wayne Barron

ASKER

Worked great, just had to add in a replace in it, and works like a champ.
(See below) 

.replace(/ /g,"_")

Open in new window


Have to remove the spaces from between the words typed in.
Love it, works great!!!