I had to rename one of my controllers as per my lawyer's recommendation and need to keep SEO and Google in mind when doing it - I still need all of the old URL's to work and/or use 301
redirects.
Redirect hint:
301
= Permanent 302
= Temporary I know there are ways to do this using the .htaccess
file but I'm not familiar with how it works and don't want to break anything.
Here are some resources on that if that's what you're looking for:
This is the easiest, SEO friendly, solution I could come up with that didn't include editing the .htaccess
file:
<?php
class Old_controller extends MY_Controller
{
function __construct() {
parent::__construct();
$this->load->helper('url');
redirect(str_replace('old_controller', 'new_controller', "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), 'location', 301);
exit();
}
}
Cheers!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.