Question: How do I move from an old url to a seo friendly url in codeigniter?
Example:
I have a codeigniter controller called library.
The URL looks like http://www.domain.com/library
This is not seo friendly and I want it to look like http://www.domain.com/keyword-library
How do I fix this? .htaccess and routing isn’t enough because I need the old pages to redirect to the new url with 301 so searchengines pick this up.
I use the application/config/routes.php to reroute new url queries to the old controller object
Then in the /index.php file before any other code executes I add this to reroute old pages to new pages.
I have tried using .htaccess for this, but for some reason I didn’t manage to make this work to reroute old urls to new urls with 301 because of the changing variables and variable lengths.
If anyone knows a more elegant solution, please post it, because I haven’t been able to find one.