using error_404.php to handle 301 redirect

#1
[eluser]Unknown[/eluser]
hi,

i have this PHP site migrated to CI framework, and the main concern is to retain the page ranking from search engine which I need the 301 redirect for old URL to the new URL (for CI).

the problem is, the paged rank URLs from the old site is too many to put in the .htaccess file. for this, i'm planning to use the error_404.php page to handle the 301 redirect which will be done thru the following steps below :

1. import all the old URLs into a database table with each corresponding new URL under CI
2. from the error_404.php, i'll try to catch the URI by using $_SERVER['REQUEST_URI'] function, then matched the URI string from the database table (step 1)
3. if the URI string is found in the database table of old URLs, perform a 301 redirect of the corresponding new URL using the header() function; if not, perform 301 redirect to the site's homepage

my question is, is my way of doing things, correct? if so, will this not affect page ranking from search engine? or how this will affect page ranking of the site?

really need inputs and advice from everyone.

thank you

#2
[eluser]Unknown[/eluser]
anybody home??

#3
[eluser]WanWizard[/eluser]
Have you tried it?

error_404 is called from the router library if the requested controller can not be found. This is way before the $CI object is created, so no access to a database. You could store them into an array, and then redirect based on an in_array() kind of test.

Alternatively you could upgrade to CI 2.0, which has a '404_override' controller in config/routes.php, which does have full access (like any other controller).


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.