• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
program redirect of links

#1
Exclamation 
Hi to everything, whether will share who the solution of one problem
the reference of a look http://my_syte/catalog/item/my_product is had
it is necessary to make 301 redirects for example on the link http://my_syte/id/2
that is the old link is stored in a database how to realize such redirection?

BAD English ON Blush
Reply

#2
Apache mod rewrite:

htaccess Tricks
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(10-01-2015, 03:48 AM)InsiteFX Wrote: Apache mod rewrite:

htaccess Tricks

your decision doesn't approach, it is necessary setting up the link from the control panel the concrete page of the site
Reply

#4
I am having trouble understand what you want. So just to clarify, your current URL is "http://my_syte/catalog/item/my_product", but you want it to be "http://my_syte/id/2"?

In either way, this is a weird relation between the two, and you will have to manually map all values. In your application/config/routes.php you can do:
PHP Code:
$route["id/2"] = "catalog/item/my_product"
Reply

#5
You could also use a _remap() function in your controller to lookup the correct information and perform the redirect.
Reply

#6
(10-01-2015, 07:14 AM)mwhitney Wrote: You could also use a _remap() function in your controller to lookup the correct information and perform the redirect.

Not really in this case. If you visit id/2 and you do not have a controller named id and method named 2, the router will not know to which controller to route to, and fail to hit your _remap() in your base controller.
Reply

#7
(10-01-2015, 11:06 PM)slax0r Wrote:
(10-01-2015, 07:14 AM)mwhitney Wrote: You could also use a _remap() function in your controller to lookup the correct information and perform the redirect.

Not really in this case. If you visit id/2 and you do not have a controller named id and method named 2, the router will not know to which controller to route to, and fail to hit your _remap() in your base controller.

I wouldn't put a _remap() function in the base controller. In fact, I think that would be a bad idea, because most of my controllers have no need for a _remap(). I would create a controller named Id with a _remap() function to point it wherever the calls need to go. If I needed to remap more URLs than just those with 'id' in the first segment, I would make more controllers.

If this was a significant problem, I would create a library to rewrite the routes and override the router to load the library. However, that would be my last-ditch approach, as it indicates that all other attempts to fix the problem have failed.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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