Simple Rewrite using mapfile.txt

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 41
Joined: 25 May 2012, 17:31

Simple Rewrite using mapfile.txt

21 Aug 2012, 16:52

Hi,

I need to do a simple rewrite such as this:

http://mywebsite.com/wholesale-w84.aspx to http://www.mywebsite.com/Wholesale

This is what I put in my mapfile.txt:

wholesale-w84.aspx Wholesale

and I put the file in the same directory as the .htaccess

I need to know the proper Rewrite Conditions and Rules please.

Much appreciated!

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Simple Rewrite using mapfile.txt

21 Aug 2012, 23:50

Hello,

Try using the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteMap mapfile txt:mapfile.txt
RewriteMap revmapfile txt:revmapfile.txt

RewriteCond ${mapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /${mapfile:$1}? [NC,R=301,L]

RewriteCond ${revmapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /${revmapfile:$1} [NC,L]


And the mapfile would have:

Code: Select all
wholesale-w84.aspx   Wholesale
wholesale-23.aspx   Wholesale23


and revmapfile would have those entries vice versa.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 7 guests