URL Rewriting with redirection |
[eluser]tzultacah[/eluser]
I was having an issue with URL rewriting with the "redirect" function. I am using the .htaccess modifications listed in the User Guide, which works great when redirection is not taking place. What was happening was this: When I clicked on links the URL rewrite was working fine, but when I used the redirect('stuff/to_thing') function, index.php was getting back into my URL. So I created a helper file "My_url_helper.php" and over-rode the redirect function as follows: Code: function redirect($uri = '', $method = 'location', $http_response_code = 302) { Code: default : header("Location: ".site_url($uri), TRUE, $http_response_code); Code: default : header("Location: ".preg_replace('#index.php\/#', '', site_url($uri)), TRUE, $http_response_code);
[eluser]xwero[/eluser]
set the index_page in the config.php file to an empty string and you don't need to change the redirect function.
[eluser]tzultacah[/eluser]
Ahhh.... good call! Thank you, I forgot all about that! ;-) |
Welcome Guest, Not a member yet? Register Sign In |