Mobile app version of vmapp.org
Login or Join
Cugini213

: One million redirects What's the best way to redirect 1,000,000 unique URLs to another 1,000,000 unique URLs? These pages are all combinations of multiple search filters and queries. We're migrating

@Cugini213

Posted in: #301Redirect #Htaccess #Redirects

What's the best way to redirect 1,000,000 unique URLs to another 1,000,000 unique URLs?

These pages are all combinations of multiple search filters and queries. We're migrating the site to cleaner URLs and want to map old pages to new ones so that we do not lose visitors or send them to 404s.

I believe a million line .htaccess will slow down the site pretty significantly. Is there a better way that would maintain PageRank but not slow down the site? Maybe something I could put on each page individually?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Cugini213

2 Comments

Sorted by latest first Latest Oldest Best

 

@Jessie594

Store your old and new redirect paths in a database.
Redirect 404 errors to a special 404 page. With Apache and PHP, you could do this with the ErrorDocument directive in your .htaccess:

ErrorDocument 404 /404.php
In the 404.php script, get the referring page with $_SERVER['REQUEST_URI'], look up the old URL path in your database, and serve a 301 redirect header to the new location if there is one, otherwise show your regular 404 page.

To issue a 301 header with PHP, you'd useheader("Location: $new_url", true, 301);


The advantage of this over Apache mod_rewrite redirects is that you don't need to process the ruleset for every request – only those that trigger a 404.

The disadvantage is that you have to create a system to manage the rewrite rules in a database, but that's probably worth doing if you have a million rules in the first place.

10% popularity Vote Up Vote Down


 

@Nickens628

You can put a meta redirect right into the HTML markup of each page. For example, put the following somewhere between <head> and </head>:

<META http-equiv="refresh" content="0;URL=/path/to/redirect/to">


Or to be more SEO friendly, add a header. For example in PHP:

header('Location: /path/to/redirect/to')

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme