Quantcast
Channel: Configuration and Deployment
Viewing all articles
Browse latest Browse all 3561

web.config configuration for rewriting subdirectories to querystrings

$
0
0

Hello

Let's say my website displays results for different restaurants in cities.

Currently my website is:

http://www.example.com/search.asp?city=Toronto&pr=Ontario
http://www.example.com/search.asp?city=Winnipeg&pr=Manitoba

city and pr(ovince) are passed to search.asp to display results.

This works fine but for SEO purposes I'd like to change it.

Ideally I'm looking to do this:

http://www.example.com/Ontario/Toronto
http://www.example.com/Manitoba/Winnipeg

to rewrite to the above querystring.

The issue is that people are able to add new cities at any time, which means that the rewrite shouldn't rely upon a pre-determined list of acceptable provinces or cities. Also I'm concerned that if I do use a rewrite, what happens if I happen to call a legitimate URL such as:

http://www.example.com/users/photos/

I wouldn't want that URL to be rewritten.

I'm feeling my best (or only) option would be something like:

http://www.example.com/places/Ontario/Toronto

and have the rewrite look for "places"

So far I've come up with: ^(.*/)www.example.com/search.asp\?city=([^=&]+)&(?:amp;)?pr=([^=&]+)$

This however doesn't work. I have difficulty with the expressions that rewriting uses and could use some assistance please.

Thank you in advance for any help.


Viewing all articles
Browse latest Browse all 3561


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>