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: mapfile is frustrating me Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
mshaffer
Newbie
Newbie


Joined: 16 May 2008
Location: United States
Online Status: Offline
Posts: 1
Posted: 16 May 2008 at 11:08am | IP Logged Quote mshaffer

Cobbling together examples I see ni this forum, I am about 98% done with everything I need, but this one little problem is killing me!

I have a CMS system that uses this URL pattern:

   default.asp?contentID=xxx

where xxx is the ID of the page. I am converting the CMS to utilize SEO friendly URLs... so I created a map file with all of the friendly names and mapped them to the unique ID's.. like so:

mypage1.htm 12
mypage2.htm 24
mypagen.htm 36
(etc)

My mapfile is called redirs.txt.

So then I have this setup in my .htaccess file (ISAPI/Rewite 3, Licensed):

RewriteEngine On
RewriteBase /
RewriteMap lower int:tolower
RewriteMap mapfile txt:redirs.txt
RewriteRule ^/$ /default.asp [L]
RewriteCond ${mapfile:${lower:$1}|NOT_FOUND} ^(?!NOT_FOUND)(.*)$
RewriteRule ^([^/]+)?$ ${mapfile:$1|$1} [R=301,L]

This works great when someone hits an old-style (unfriendly) URL like this:

http://www.mydomain.com/default.asp?contentid=24

It also works great when someone types:

http://www.mydomain.com/mypage2.htm

(redirects internally to the default.asp?contentID=24)

But what is screwed up is when someone just types:

http://www.mydomain.com/

I end up getting a fouled up at this point, either getting a weird long URL with all kinds of stuff like this:

http://www.mydomain.com/$%7Bmapfile:$%7Bmapfile:$%7Bmapfile:$%7Bmapfile:$%7Bmapfile:|%7D|$%7Bmapfile:|%7D%7D|$%7Bmapfile:$%7Bmapfile:|%7D|$%7Bmapfile:|%7D%7D%7D|$%7Bmapfile:$%7Bmapfile:$%7Bmapfile:|%7D

OR (if I keep tweaking it) I get various 404 errors, etc.

I'm sure it's something simple I'm missing... but it's killing me with the amount of time I'm spending trying to figure it out. Anybody out there understand what is going on here?

   Thanks!

 



Edited by mshaffer - 16 May 2008 at 11:09am
Back to Top View mshaffer's Profile Search for other posts by mshaffer
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4178
Posted: 19 May 2008 at 3:48am | IP Logged Quote Anton

Please try to utilize the following config:

RewriteEngine On
RewriteBase /
RewriteMap lower int:tolower
RewriteMap mapfile txt:redirs.txt
RewriteRule ^$ /default.asp [L]
RewriteCond ${mapfile:${lower:$1}|NOT_FOUND} ^(?!NOT_FOUND)(.*)$ RewriteRule ^([^/]+)$ ${mapfile:$1|$1} [R=301,L]


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

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 cannot vote in polls in this forum