How can i do a redirect pre-systme hook ? |
[eluser]bhenbe[/eluser]
Hi all, for an unknown reason, a redirect in a pre_system hook doesn't work. It's the first time i try this. I need to redirect some urls if they are listed in a database. So, something like http://www.mysite.com/code-igniter can be a redirect and not a controller. Here's my code : Config hook : Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Hook Direct_access : Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); I changed the return code by an echo to check each part of my code. Nothing's wrong but the Header function doesn't work. CI always show me a 404 page because the controller doesn't exist. Anyone have an idea ? Thanks !
[eluser]toopay[/eluser]
Change Code: Header('Location: '.$row['redirect']); Code: header("Location: $row['redirect']");
[eluser]bhenbe[/eluser]
Thanks ! You must also check if $row doesn't return false. Without this check, exit will stop the controller calls. Code: $query = sprintf("SELECT `redirect` FROM `direct_access` WHERE `url` LIKE '%s'", mysql_real_escape_string($url)); |
Welcome Guest, Not a member yet? Register Sign In |