Cakephp Does Not Redirect on the Online Server

Asked

Viewed 418 times

3

Good morning!

I’m using the cakephp framework, but I’m having a problem with no solution so far... I have a login controller, commented all the login code and left only the tree

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

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

I’ve checked spaces in Index, Routes, Controller and View files, but no spaces before the php opening tag I’ve tried opening php only with

<?

I 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 to direct.
I’ve already released debug mode to print errors, but msm so no errors are reported, neither visually nor in the bug logo.

  • Well, you’ve already said that you’ve checked for blanks, but most of the problems related to or similar to yours accuse you of this problem. I hope this link helps you: http://stackoverflow.com/questions/16130309/cakephp-redirect-not-workin

  • I also noticed that flash sessions are not being generated...

  • @Rafaelwithoeft Thanks for commenting, I have already read this link and performed those steps of the "fixed" question, but still did not correct.

  • Did you check the folder permissions? (Probably the documentation should provide which folders are permissions accurate and which level)...

  • @Rafaelwithoeft everything is with full permission (777)... If the problem was permission I probably could not access via url, correct?

  • I believe I would access normally, because the files by default have read permission... etc, I commented on the permissions pq, I use Yii2, and permissions are required in some folders and when I first put on the server the application did not work as it should, some pages didn’t load (I don’t remember exactly what didn’t work, it’s been a long time...), I looked and noticed the permissions that were wrong... Besides having read some report related to your case, of permissions in some file, Auth if I’m not mistaken. Of course I could be wrong about that.

  • @Rafaelwithoeft I released the permissions again, but even so it didn’t help, I don’t really know what else to do, the only thing I haven’t done is reopen all the files encoding with UTF-8, but it has a lot of file this project, If I’m gonna do this literally to everyone, I’m screwed. Thanks for the help @Rafaelwithoeft!

Show 2 more comments

2 answers

1

After 3 days fighting and some "sleepless" nights,.

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

For my happiness, I found around 5 files that had this problem, after fixing these files it seems that the targeting and session came back to work.

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

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

or

?>
(quebra de linha ou espaço)

After removing these occurrences, it seems that everything is back to normal.
I had one more steering problem, but I think this is a little different.

Thanks for all your help!

0

This problem is common when there are sent headers. In place of redirect, try using the following and see which error is returned:

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

When using redirect, it’s good practice to add it to Return:

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

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

if (headers_sent($file, $line)) {
    exit("headers were already sent in file: {$file}, line number: {$line}");
}
  • Thanks for the help Marcelo. I had seen something like what you posted, I tried but I didn’t get much. This morning I managed to solve, I will post the solution I found. But, anyway, Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.