Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0 support forum
 Helicon Tech : ISAPI_Rewrite 3.0 support forum
Subject Topic: Redirect only from mapfile Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
richardh
Newbie
Newbie


Joined: 06 October 2008
Online Status: Offline
Posts: 8
Posted: 06 October 2008 at 7:35am | IP Logged Quote richardh

I have installed the trial version of isapi_rewrite 3 on IIS5, and have a mapfile working happily.

Here's my current .htaccess

RewriteEngine on

RewriteBase /

RewriteMap mapfile txt:menu/mapfile.txt

RewriteMap lower int:tolower

RewriteRule (?!images|Files|js|menu|default.css|results.asp|index.css|default.asp)(^(.+)$) /item.asp?cid=${mapfile:${lower:$1}}

#RewriteRule ^(.+)$ /item.asp?cid=${mapfile:${lower:$1}}

Is there a way of writing it so that I don't have to specify all the items I want to ignore - i.e. if the page exists in the mapfile then it is used, otherwise the original URL is used?

Also, I am only using this on a single site on the server, so is it sensible to uninstall then do a manual install and point it solely at this site, rather than running it by default?

Great piece of software!

Richard

Back to Top View richardh's Profile Search for other posts by richardh
 
Vyacheslav
Moderator Group
Moderator Group


Joined: 02 July 2008
Location: Ukraine
Online Status: Offline
Posts: 673
Posted: 06 October 2008 at 9:20am | IP Logged Quote Vyacheslav

Hi Richard,
Please try this solution:
Code:
RewriteEngine on

RewriteBase /

RewriteMap mapfile txt:menu/mapfile.txt
RewriteMap lower int:tolower

RewriteCond %{REQUEST_URI} (?!images|Files|js|menu|default\.css|results\.asp|index\.css|default\.asp)(^(.+)$) [NC]
RewriteCond ${mapfile:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /item.asp?cid=${mapfile:${lower:%1}}


__________________
Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
Back to Top View Vyacheslav's Profile Search for other posts by Vyacheslav Visit Vyacheslav's Homepage
 
richardh
Newbie
Newbie


Joined: 06 October 2008
Online Status: Offline
Posts: 8
Posted: 09 October 2008 at 3:50am | IP Logged Quote richardh

That's great - seems to do the job nicely, after a little tweak to the mapfile (needed to add the leading forward slash to the items in the mapfile).

Is there a way of using more than one mapfile?

 

EDIT - looks like I have found the answer

http://www.helicontech.com/forum/forum_posts-TID-10032.htm



Edited by richardh - 09 October 2008 at 4:04am
Back to Top View richardh's Profile Search for other posts by richardh
 
richardh
Newbie
Newbie


Joined: 06 October 2008
Online Status: Offline
Posts: 8
Posted: 13 October 2008 at 11:03am | IP Logged Quote richardh

Vyacheslav, can I pick your brains once more, please?

Is it possible to tweak this rule so that if the stem of the URL is found in the mapfile, it passes anything beyond that in as separate parameters? For example, say I have an entry in the map file like this:

Code:
/giftware/clocks/watches 75

With a URL of www.mydomain.com/giftware/clocks/watches , using the rule I have above, that would go to item.asp?cid=75. However, if I then wanted to be able to do paging, so a URL might look like

www.mydomain.com/giftware/clocks/watches/page2

Can I have the "end" of the URL pass into another parameter so the resultant url would be item.asp?cid=75&p=2 - even though I'm looking it up in a mapfile?

Actually, another thought - if I wanted to link to a product at the end of this URL - i.e.

www.mydomain.com/giftware/clocks/watches/TDB1234

Where TDB1234 is a product code, that does not follow a particular format (i.e. a code could be 123DD4, QQQfg5, etc) is it possible to link to  a product detail page in that case

so - if the end part is /pagexxx then link to one URL with a p=xxx parameter, otherwise link to a different url with productID=TDB1234

Not asking much, am I?

 

 



Edited by richardh - 13 October 2008 at 12:29pm
Back to Top View richardh's Profile Search for other posts by richardh
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4837
Posted: 14 October 2008 at 5:16am | IP Logged Quote Anton

Please try to use the following config:

RewriteEngine on
RewriteBase /
RewriteMap mapfile txt:menu/mapfile.txt
RewriteMap lower int:tolower
RewriteCond %{REQUEST_URI} ^(?!images|Files|js|menu|default\.css|results\.asp|index\.css|default\.asp)(.+)/page(\d+)$ [NC]
RewriteCond ${mapfile:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /item.asp?cid=${mapfile:${lower:%1}}&p=%2

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
richardh
Newbie
Newbie


Joined: 06 October 2008
Online Status: Offline
Posts: 8
Posted: 14 October 2008 at 12:13pm | IP Logged Quote richardh

Thanks again - does the trick nicely!
Back to Top View richardh's Profile Search for other posts by richardh
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum