Register FAQ Search Today's Posts Mark Forums Read
Miva Merchant Community Forums
User Name
Password
RayYates
  #1  
Old Posted: 11-25-08, 05:03 AM
Developer Partner
RayYates's Avatar
Joined Dec 2006
Posts: 737 RayYates is on a distinguished road
301 redirects huge htaccess file
Is there a way to dynamicly lookup old urls and redirect to a new url using php and MySQL.

Here is the problem:
With the advice of an seo specialist. my client has changed the short link style used in MM4 to a new format.

domain.com/product_OR_categorycode.html has become
domain.com/productcode_categorycode.html

In most cases the category codes have change to something more seo friendly and many of the product codes have also changed as well.

To make this work they did 301 redirects in the htaccess file... 25000 times.

Since htaccess gets parced for each server request (including pages, images, css and javascript files) Thir site has take a very visible performance hit.

It would seem their must be a way to do dynamicly lookup the old code(s) and redirect to a new url using php and MySQL.

Any Ideas?

Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
PCI Net: http://www.pcinet-llc.com/
PCI Net Toolbelt: http://www.mivacentral.com/Merchant2...&partnerpage=1
PCI Net Toolbelt Documentation: http://www.pcinet-llc.com/docs/toolbelt_docs.shtml
 
Reply With Quote
TipPro
  #2  
Old Posted: 11-25-08, 05:54 AM
Mivite
TipPro's Avatar
Joined Apr 2006
Posts: 197 TipPro is on a distinguished road
Re: 301 redirects huge htaccess file
Do you mean the old link looked like...

domain.com/product.html

OR

domain.com/categorycode.html

Or that the actual word "OR" was in the url?

Is the product the same thing as productcode?
 
Reply With Quote
RayYates
  #3  
Old Posted: 11-25-08, 06:42 AM
Developer Partner
RayYates's Avatar
Joined Dec 2006
Posts: 737 RayYates is on a distinguished road
Re: 301 redirects huge htaccess file
domain.com/productcode.html

OR

domain.com/categorycode.html

They hade a module that would differentiate between the two and redirect to the correct page.

I should say they moved from MM4 toMM5.5

Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
PCI Net: http://www.pcinet-llc.com/
PCI Net Toolbelt: http://www.mivacentral.com/Merchant2...&partnerpage=1
PCI Net Toolbelt Documentation: http://www.pcinet-llc.com/docs/toolbelt_docs.shtml
Last edited by RayYates; 11-25-08 at 06:53 AM..
 
Reply With Quote
Brandon MUS
  #4  
Old Posted: 11-25-08, 07:07 AM
Mega Mivite
Joined Mar 2006
Posts: 1,511 Brandon MUS is on a distinguished road
Re: 301 redirects huge htaccess file
since the rewrites are in the root, it might be very hard to make rules. You can try using rewrites using
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
to check if the file exists. It really depends what the URL was and what it becomes. If there's a pattern, you can combine the rules.

If there isn't a pattern, what I have done in the past is used a template to create static html files that redirect to the new page. Creating 25000 files might suck, so if you're bored you can create a PHP script to generate (write to) the needed files?

Here's the template I use:
Code:
<?php
	header("HTTP/1.0 301 Moved Permanently");
	header("Location: http://www.mydomain.com/path_to_file.html");
 
Reply With Quote
Biffy
  #5  
Old Posted: 11-25-08, 07:24 AM
Mega Mivite
Biffy's Avatar
Joined Aug 2006
Posts: 1,626 Biffy is on a distinguished road
Re: 301 redirects huge htaccess file
Naturally the Big G doesn't like HTML redirects. They prefer 301s.

I have the same problem doing an upgrade from old SEO to new SEO.

Steve Strickland
Ecommerce Retail
steve@ecommerce-retail.com
972-677-7663
 
Reply With Quote
RayYates
  #6  
Old Posted: 11-25-08, 07:31 AM
Developer Partner
RayYates's Avatar
Joined Dec 2006
Posts: 737 RayYates is on a distinguished road
Re: 301 redirects huge htaccess file
Dave @ hostasaurus pointed me to

http://httpd.apache.org/docs/2.2/mod...tml#rewritemap

Untested. I think I can do this in htaccess

RewriteMap map301 prg:remap.mvc
RewriteRule ^/(.*).html$ {map301:$1}

Now I just have to write remap.mvc

Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
PCI Net: http://www.pcinet-llc.com/
PCI Net Toolbelt: http://www.mivacentral.com/Merchant2...&partnerpage=1
PCI Net Toolbelt Documentation: http://www.pcinet-llc.com/docs/toolbelt_docs.shtml
 
Reply With Quote
Brandon MUS
  #7  
Old Posted: 11-25-08, 07:54 AM
Mega Mivite
Joined Mar 2006
Posts: 1,511 Brandon MUS is on a distinguished road
Re: 301 redirects huge htaccess file
Quote:
Originally Posted by Biffy
Naturally the Big G doesn't like HTML redirects. They prefer 301s.

I have the same problem doing an upgrade from old SEO to new SEO.
I think you're referring to meta redirects. A PHP redirect like I showed would pass proper headers (very similar to what Apache would do). Even if not, Big G will have to just deal with it -- there's no way I'd do 25000 redirect rules just to keep them happy.

Is RewriteMap going to be any more efficient? It is still going to be processed on every request, right? I always thought it was just there for ease of upkeep.
 
Reply With Quote
RayYates
  #8  
Old Posted: 11-25-08, 08:00 AM
Developer Partner
RayYates's Avatar
Joined Dec 2006
Posts: 737 RayYates is on a distinguished road
Re: 301 redirects huge htaccess file
I was thinking of putting the records in a MYSQL table old, new with an index on the old code. Then the mvc program would just lookup the old code and return the new url.

I think we can do this in apache config so that it only does this lookup on .html files and not on every server request.

Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
PCI Net: http://www.pcinet-llc.com/
PCI Net Toolbelt: http://www.mivacentral.com/Merchant2...&partnerpage=1
PCI Net Toolbelt Documentation: http://www.pcinet-llc.com/docs/toolbelt_docs.shtml
 
Reply With Quote
Bruce - PhosphorMedia
  #9  
Old Posted: 11-25-08, 08:50 AM
Developer Partner
Bruce - PhosphorMedia's Avatar
Joined Mar 2006
Posts: 4,225 Bruce - PhosphorMedia is on a distinguished road
Re: 301 redirects huge htaccess file
Well, strickly speaking...that huge redirect file would only need to be in place for a short while...until all the search engines redirect the links based on it. With Google, you should be able to submit a sitemap.xml file (using the OLD links) and once that is accepted, Google should only be listing the new urls (could be tested with an INURL search).

 
Reply With Quote
ILoveHostasaurus
  #10  
Old Posted: 11-25-08, 08:52 AM
Web Host Partner
ILoveHostasaurus's Avatar
Joined Mar 2006
Posts: 2,815 ILoveHostasaurus is on a distinguished road
Re: 301 redirects huge htaccess file
Quote:
Originally Posted by Brandon MUS
I think you're referring to meta redirects. A PHP redirect like I showed would pass proper headers (very similar to what Apache would do).

Is RewriteMap going to be any more efficient? It is still going to be processed on every request, right? I always thought it was just there for ease of upkeep.
Correct on the php, that is precisely the same thing apache sends back.

RewriteMap is very efficient because it's loaded into memory as part of the server config rather than in .htaccess, and it's just a few statements rather than 25,000.

David

Hostasaurus.Com
MIVA Premier Hosting Partner
877.346.6769 for Sales & Support
813.217.4570 (International)
 
Reply With Quote
Reply Reply to Thread

Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 02:14 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.