CakePhp does not redirect to the Online server

3

Good morning!

I'm using the cakephp framework, but I have a problem with no solution so far ... I have a login controller, I commented the entire login code and left only the trex

  

$ this-> redirect (array ('controller' => 'nomedocontorller', 'action' = > 'home'));

In localhost this command works normally, I can direct the url, however, when I put it on the online server I simply get a blank page and no error message.

I have already checked spaces in the Index, routes, Controller, and View files, but there are no spaces before the php opening tag I've already tried opening php just with

  

<?

I have already uploaded a new cakePHP framework to the server to test if the problem was hidden in any of the files, but msm with the default cakephp files continued not directing. I have already released debug mode to start the errors, but more so no error is reported, neither visually nor in the error log.

    
asked by anonymous 22.05.2015 / 15:43

2 answers

1

After three days of fighting and some sleepless nights, I confess that I was already discouraged.

Today I woke up inspired to solve this problem and started to search the project for php tags that had empty spaces before or after the opening / closing.

To my happiness, I found around 5 files that had this problem, after correcting these files it seems that the targeting and session started working again.

Solution: Search for php tags that were opened / closed before or after the tags
Example:

(quebra de linha ou espaço)
<?php

or

?>
(quebra de linha ou espaço)

After removing these occurrences, it appears that everything has returned to normal. I had one more targeting problem, but I think it's a bit different.

Thanks for everyone's help!

    
25.05.2015 / 21:42
0

This problem is common when headers are sent. Instead of redirect, try to use the following and see which error is returned:

<?php header( 'Location: http://www.google.com/' ) ; ?>

When using redirect, it is good practice to add it to return:

return $this->redirect(array('action' => 'index'));

In your action, add the debug below and note the return:

if (headers_sent($file, $line)) {
    exit("headers were already sent in file: {$file}, line number: {$line}");
}
    
25.05.2015 / 16:10