| Author |
|
RiaanBotha Newbie

Joined: 28 August 2007 Location: South Africa
Online Status: Offline Posts: 15
|
| Posted: 01 October 2008 at 7:43am | IP Logged
|
|
|
Hi,
Our site, www.journeys2africa.com is using ISAPI-Rewrite at the moment.
Its been working great and we have over 7000 pages indexed in Google. Problem is that we have a new website and want to redirect the old URL's to the new ones. After that, the new ones need to be rewritten to a more friendly structure.
The old ID's are no more either, I do however have a file containing the old and new id's with product names.
EG:
Old URL: http://www.journeys2africa.com/j2a/accommodation/ID~362~accom-estdetail.cfm
New URL: http://www.journeys2africa.com/default/index.cfm/hotels-lodges/establishment-details/?AccommodationID=1&ServiceType=AC
New URL rewritten: http://www.journeys2africa.com/hotels-lodges/Hermanus/Abalone-Guest-Lodge
This all seems very daunting...can anyone give me an idea where to start?
Edited by RiaanBotha - 01 October 2008 at 7:46am
__________________ *Insert fancy Title here
|
| Back to Top |
|
| |
Vyacheslav Moderator Group

Joined: 02 July 2008 Location: Ukraine
Online Status: Offline Posts: 673
|
| Posted: 01 October 2008 at 8:36am | IP Logged
|
|
|
Hi,
You can try map-files feature.
Here is an example for you:
Code:
RewriteMap lower int:tolower
# If it an old URL, then we must redirect it to a new
RewriteMap OldMap txt:oldmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${OldMap:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? ${OldMap:${lower:%1}} [NC,R=301]
# Rewriting a new URL
RewriteMap NewMap txt:newmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${NewMap:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? ${NewMap:${lower:%1}} [NC,L]
|
|
|
oldmap.txt:
Code:
/j2a/accommodation/ID~362~accom-estdetail.cfm /hotels-lodges/Hermanus/Abalone-Guest-Lodge
|
|
|
newmap.txt:
Code:
/hotels-lodges/Hermanus/Abalone-Guest-Lodge /default/index.cfm/hotels-lodges/establishment-details/?AccommodationID=1&ServiceType=AC
|
|
|
__________________ Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
|
| Back to Top |
|
| |
RiaanBotha Newbie

Joined: 28 August 2007 Location: South Africa
Online Status: Offline Posts: 15
|
| Posted: 01 October 2008 at 8:50am | IP Logged
|
|
|
Will Try this out and let you know. Thanks !
__________________ *Insert fancy Title here
|
| Back to Top |
|
| |
RiaanBotha Newbie

Joined: 28 August 2007 Location: South Africa
Online Status: Offline Posts: 15
|
| Posted: 06 October 2008 at 8:25am | IP Logged
|
|
|
Hi,
I upgraded to ISAPI Rewrite 3, used the above example in the .htaccess file and created oldmap and newmap as suggested.
I am getting the following errors: Errors.txt
Thanks Riaan
__________________ *Insert fancy Title here
|
| Back to Top |
|
| |
Vyacheslav Moderator Group

Joined: 02 July 2008 Location: Ukraine
Online Status: Offline Posts: 673
|
| Posted: 06 October 2008 at 9:37am | IP Logged
|
|
|
Hi Riaan,
Please try this:
Code:
# If it an old URL, then we must redirect it to a new
RewriteMap OldMap txt:oldmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${OldMap:%1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${OldMap:%1} [NC,R=301]
# Rewriting a new URL
RewriteMap NewMap txt:newmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${NewMap:%1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${NewMap:%1} [NC,L] |
|
|
__________________ Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
|
| Back to Top |
|
| |
RiaanBotha Newbie

Joined: 28 August 2007 Location: South Africa
Online Status: Offline Posts: 15
|
| Posted: 07 October 2008 at 4:24am | IP Logged
|
|
|
Whoowee!
Thanx a million! Works beautifully.
__________________ *Insert fancy Title here
|
| Back to Top |
|
| |
RiaanBotha Newbie

Joined: 28 August 2007 Location: South Africa
Online Status: Offline Posts: 15
|
| Posted: 07 October 2008 at 11:37am | IP Logged
|
|
|
Hi Vyacheslav,
The old pages are now redirecting to the new, pretty URL's, but the new content needs to be redirected aswell.
I have created another map-file and used your example as follows:
Code:
|
# If it an old URL, then we must redirect it to a new RewriteMap OldMap txt:C:/Inetpub/wwwroot/sava/default/oldmap.txt RewriteCond %{REQUEST_URI} (.*) RewriteCond ${OldMap:%1|NOT_FOUND} !NOT_FOUND [NC] RewriteRule .? ${OldMap:%1} [NC,R=301]
# If it an Ugly-New URL, then we must redirect it to a Pretty URL RewriteMap prettymap txt:C:/Inetpub/wwwroot/sava/default/prettymap.txt RewriteCond %{REQUEST_URI} (.*) RewriteCond ${prettyMap:%1|NOT_FOUND} !NOT_FOUND [NC] RewriteRule .? ${prettyMap:%1} [NC,R=301]
# Rewriting a new URL RewriteMap NewMap txt:C:/Inetpub/wwwroot/sava/default/newmap.txt RewriteCond %{REQUEST_URI} (.*) RewriteCond ${NewMap:%1|NOT_FOUND} !NOT_FOUND [NC] RewriteRule .? ${NewMap:%1} [NC,L]
|
|
|
I am getting these errors: errors.txt
It seems to be cutting the URL off at the questionmark.
Thanks Riaan
__________________ *Insert fancy Title here
|
| Back to Top |
|
| |
Vyacheslav Moderator Group

Joined: 02 July 2008 Location: Ukraine
Online Status: Offline Posts: 673
|
| Posted: 08 October 2008 at 3:01am | IP Logged
|
|
|
Hi Riaan,
Please try this:
Code:
# If it an old URL, then we must redirect it to a new
RewriteMap OldMap txt:C:/Inetpub/wwwroot/sava/default/oldmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${OldMap:%1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${OldMap:%1} [NC,R=301]
# If it an Ugly-New URL, then we must redirect it to a Pretty URL
RewriteMap prettyMap txt:C:/Inetpub/wwwroot/sava/default/prettymap.txt
RewriteCond %{QUERY_STRING} (.*)
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${prettyMap:%1\?%2|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${prettyMap:%1\?%2} [NC,R=301]
# Rewriting a new URL
RewriteMap NewMap txt:C:/Inetpub/wwwroot/sava/default/newmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${NewMap:%1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${NewMap:%1} [NC,L]
|
|
|
__________________ Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
|
| Back to Top |
|
| |
RiaanBotha Newbie

Joined: 28 August 2007 Location: South Africa
Online Status: Offline Posts: 15
|
| Posted: 13 October 2008 at 9:05am | IP Logged
|
|
|
Hi again,
I used the above code, but it does not work yet. I tried playing around with it myself, but only managed to confuse the whole site.
I swapped "RewriteCond %{QUERY_STRING} (.*)
" and "RewriteCond %{REQUEST_URI} (.*)" around and it almost worked but added the Query string onto the end of the rewritten URL.
Here are the errors I am getting with the code you supplied last.
Errors.txt
__________________ *Insert fancy Title here
|
| Back to Top |
|
| |
Vyacheslav Moderator Group

Joined: 02 July 2008 Location: Ukraine
Online Status: Offline Posts: 673
|
| Posted: 14 October 2008 at 8:19am | IP Logged
|
|
|
Hi, Excuse me, it's my mistake. Yes, you are right, these conditions must be swapped.
Please try these rules:
Code:
# If it an old URL, then we must redirect it to a new
RewriteMap OldMap txt:C:/Inetpub/wwwroot/sava/default/oldmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${OldMap:%1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${OldMap:%1} [NC,R=301]
# If it an Ugly-New URL, then we must redirect it to a Pretty URL
RewriteMap prettyMap txt:C:/Inetpub/wwwroot/sava/default/prettymap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond %{QUERY_STRING} (.*)
RewriteCond ${prettyMap:%1\?%2|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${prettyMap:%1\?%2}? [NC,R=301]
# Rewriting a new URL
RewriteMap NewMap txt:C:/Inetpub/wwwroot/sava/default/newmap.txt
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${NewMap:%1|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${NewMap:%1} [NC,L] |
|
|
__________________ Kind regards!
Vyacheslav Shinkarenko, HeliconTech.
|
| Back to Top |
|
| |
RiaanBotha Newbie

Joined: 28 August 2007 Location: South Africa
Online Status: Offline Posts: 15
|
| Posted: 07 November 2008 at 10:36am | IP Logged
|
|
|
HI!
Our site is live and its awesome, thanks. Still have a lot of work to do, but I'm very proud of it so far.
I have noticed that the map is case sensitive.
...ID~345... will be redirected but not ...id~345...
Here is the original code:
Code:
# If it an old URL, then we must redirect it to a new RewriteMap OldMap txt:C:/Inetpub/wwwroot/sava/default/oldmap.txt RewriteCond %{REQUEST_URI} (.*) RewriteCond ${OldMap:%1|NOT_FOUND} !NOT_FOUND [NC] RewriteRule .? ${OldMap:%1} [NC,R=301]
|
|
|
And here is the modified code I wrote that is not working:
Code:
# If it an old URL, then we must redirect it to a new RewriteMap OldMap txt:C:/Inetpub/wwwroot/sava/default/oldmap.txt RewriteMap lower int:tolower RewriteCond %{REQUEST_URI} (.*) RewriteCond ${OldMap:%{lower:%1}|NOT_FOUND} !NOT_FOUND [NC] RewriteRule .? ${OldMap:%{lower:%1}} [NC,R=301]
|
|
|
Just when I thought I sort of understood this stuff. Was I at least on the right track?
Thanks Riaan
__________________ *Insert fancy Title here
|
| Back to Top |
|
| |
Anton Moderator Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 4837
|
| Posted: 10 November 2008 at 2:46am | IP Logged
|
|
|
In addition to your corrections (which I have fixed a bit below) you should change all records in your map file to lower case.
RewriteMap OldMap txt:C:/Inetpub/wwwroot/sava/default/oldmap.txt
RewriteMap lower int:tolower
RewriteCond %{REQUEST_URI} (.*)
RewriteCond ${OldMap:${lower:%1}|NOT_FOUND} !NOT_FOUND [NC]
RewriteRule .? ${OldMap:${lower:%1}} [NC,R=301]
__________________ Regards,
Anton
|
| Back to Top |
|
| |