Forum Moderators: open

Message Too Old, No Replies

ISAPI Rewrite

RegExp making my head warm...

         

cococure

7:53 pm on Jun 26, 2003 (gmt 0)

10+ Year Member



Ok, I guess years of running away from regular expressions is coming back to kick me in the butt. I am having a little difficulty trying to get this done correctly and I am hoping someone can help.

On our site, I want these urls:

[domain.com...]

to be a "virtual" URL (via ISAPI Rewrite):

[domain.com...]

I am using the product name in the url, but don't actually need it in the actual url.

I have come across several regular expressions, but heck if I know which one is right:

RewriteRule /(.*)\.htm /detail.asp\?product_id=$1

or

rewriteRule (.*)\.asp\?([^=].*)=(.*) $1/$2/$3.asp

What is important is that "detail.asp" be included into the regEx because we are using custom 404.asp pages and don't want to mess with that.

jdMorgan

8:47 pm on Jun 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



cococure,

Welcome to WebmasterWorld [webmasterworld.com]!

Addressing only the regular-expressions issue (I can't tell you if your approach will work, since I'm in the Apache camp, where this would work):

This rule will find "fbwNNN.htm" in the Funky-Blue-Widget subdirectory, and rewrite it to /detail.asp\?product_id=fbwNNN, where fbwNNN is the product code (only).

RewriteRule ^/Funky-Blue-Widget/(.*)\.htm$ /detail.asp\?product_id=$1 [L]

This would work fine on Apache, but I'm not sure you need (or can have) the [L] flag, or even if this will work at all on non-Apache servers.

The basic approach is to have all your pages, including script-generated pages, refer to static-looking URLs. When a request for a static-looking URL in the Funky-Blue-Widget subdirectory comes back from the user's browser, it is converted to the proper format needed to call your script. Since all URLs which are visible to the outside world are "friendly" URLs, that's what the search engines will index.

HTH,
Jim

cococure

7:28 pm on Jun 27, 2003 (gmt 0)

10+ Year Member



jdMorgan,

Thanks. That is on the right track. "Funky Blue Widget" isn't a true subdirectory, it's actually the product name. So in more generic terms the links would be:

[domain.com...]

the "real" url would be

[domain.com...]

Thanks.