Domanda

I'm having a problem with CI 2.1.3 redirect function.

Everytime I call redirect, it shows a white-blank page. In fact, it works well on my localhost, the problem just occurs on my real server (with CentOS 5 installed).

This is how I call the redirects :

redirect('frontend/article/index');

or

redirect(base_url('articles.html'));

I did add a route in config/routes.php

$route['articles.html'] = 'frontend/article/index';

with : frontend is module, article is controller, and index is action (I'm using wiredesignz's HMVC module extension)

How could I fix it? And what is the problem here?

Thanks in advance!

UPDATE

I replaced CI redirect function by calling :

header("Location: http://example.com");

but it didn't work too.

So I created a file named info.php and uploaded it to my server. Here's the content:

<?php
phpinfo();
?>

When I type in the address bar : http://example.com/info.php, it shows like in the image.

enter image description here

Why was there a ">" character? Was it the problem causing redirect not working?

È stato utile?

Soluzione

Firstly, make sure error reporting is enabled, or try placing the following at the top of your index.php.

error_reporting(E_ALL | E_WARNING | E_NOTICE);
ini_set('display_errors', TRUE);

If this doesn't point you in the right direction make sure you don't have any output echo, print_r, print, dump, etc before your call to redirect() method.

Another common cause or problems when moving to a new environment is white space. Check that your files don't have any whitespace at the bottom of them.

Altri suggerimenti

if you are defining .html in the config.php as the file ext. you do not need to postfix the route with it.

$route['articles'] //instead of $route['articles.html']

Also you need to remove the base_url() from the redirect cos that is not needed.

redirect('articles'); //should sort it

Hope this sorts ur problems.

EDIT

If this is still not working after attempting these changes, it will most likely be a problem in the controllers. If this is the case you may need to turn on error reporting in your index.php file to find out exactly where the problem is occurring.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top