Welcome Guest, Not a member yet? Register   Sign In
How can I do a redirect with CodeIgniter?

I had a wordpress site before I built my site with codeigniter. I was getting a fair amount of traffic to those wordpress pages but replaced the site with a totally different layout and codeigniter instead of wordpress.

I have a lot of pages cached by Google in the form of www.website.com/category/post. I have a 1 page style site now. I'm not sue how to do the redirects from the old pages to the new page. Any help you can give is appreciated

You have a number of options, including setting a default controller with a remap function to redirect requests for known locations. Given that the old URLs are in the form category/post, though, you may just want to create a category controller to handle those (if your routes and URL rewrites are setup that way).

It may even be possible to handle this in your routes config, but that really depends on how you intend to handle those requests.

As mwhitney said, it depends on your data. What you need is a matching key for e.g. an database ID. Then you can remap you're old link structure as route roule.

PHP Code:
$route['/category/post/(:any)'] = '/your_controller/$1'

In the example above you have an old url like (http://.../category/post/123). The visitor will be redirect by the roule to http://.../your_controller/123


Thanks! I will try the route option and let you know

Theme © iAndrew 2016 - Forum software by © MyBB