Simple Rewrite using mapfile.txt
2 posts
• Page 1 of 1
Simple Rewrite using mapfile.txt
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!
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!
- HeliconAndrew
-
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Simple Rewrite using mapfile.txt
Hello,
Try using the following:
And the mapfile would have:
and revmapfile would have those entries vice versa.
Regards
Andrew
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
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests