$ this-> request-> referer () doesn't work as expected (CakePHP 2)

There may be many questions on this, but no help from all of these ... I have the same problem as following this link .

I am asking url http://example.com/projects/phase/test_phase2#5591409f-ce8c-4a8a-a92d-77360a11ef94 to save progress and this is asking for the url http://example.com/phases/update_progress . now i want to redirect my page back to url. I use it all. But no luck.

$this->redirect($this->referer('/'));
$this->redirect($this->referer());
$this->redirect($this->request->referer());
$this->redirect( Router::url( $this->referer(), true ) );

      

after that it redirects to http://example.com/phases/example.com But I want it to redirect to http://example.com/projects/phase/test_phase2#5591409f-ce8c-4a8a-a92d-77360a11ef94 .

routes.php

Router::parseExtensions('json');
Router::connect('/', array('controller' => 'dashboard', 'action' => 'index'));
Router::connect('/admin', array('controller' => 'dashboard', 'action' => 'index', 'admin' => true));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/admin/login', array('controller' => 'users', 'action' => 'login', 'admin' => true));
Router::connect('/contents/*', array('controller' => 'contents', 'action' => 'view'));

      

.htaccess -

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

      

it works very well on localhost. All files are the same on both servers.

Is there any other way to do this?

+3


source to share


1 answer


I tried to solve this problem by creating a HistoryComponent that stores requests in the user's session (including get parameters). The obvious downside to this approach is that it relies on sessions. Because the session is the same across all tabs, the feedback buttons can affect each other in a multi-tab environment.

If you want to use it:



  • Add plugin to bootstrap.php
  • Use the variable previous_page in your view (go to the back button)
0


source







All Articles