简体   繁体   English

$ this-> request-> referer()无法正常工作(Cakephp 2)

[英]$this->request->referer() not working properly (Cakephp 2)

There may be a lot of question regarding this but no help from these all . 关于这一点可能有很多问题,但这些都没有帮助。 . I have the same issue as On this link . 我有与此链接相同的问题。

I am requesting from url http://example.com/projects/phase/test_phase2#5591409f-ce8c-4a8a-a92d-77360a11ef94 to save the progress and this is requesting on the url http://example.com/phases/update_progress . 我从网址http://example.com/projects/phase/test_phase2#5591409f-ce8c-4a8a-a92d-77360a11ef94请求保存进度,这是在网址上请求http://example.com/phases/update_progress now i want to redirect my page on back to the url . 现在我想将我的页面重定向回到网址。 I am using these 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 this it is redirecting to http://example.com/phases/example.com But i want it to be redirect on http://example.com/projects/phase/test_phase2#5591409f-ce8c-4a8a-a92d-77360a11ef94 . 在此之后,它将重定向到http://example.com/phases/example.com但我希望它可以重定向到http://example.com/projects/phase/test_phase2#5591409f-ce8c-4a8a-a92d-77360a11ef94

routes.php is 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 is .htaccess是

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

it is working very well on localhost . 它在localhost上运行得很好。 All files are same on both server. 两台服务器上的所有文件都相同。

Is there any other method to do this ?? 还有其他方法吗?

I tried to solve this issue by creating a HistoryComponent that saves the requests in the user's session (including the get parameters). 我试图通过创建一个在用户会话中保存请求的HistoryComponent来解决这个问题(包括get参数)。 The obvious disadvantage of this approach is that it relies on sessions. 这种方法的明显缺点是它依赖于会话。 Since the session is the same in all tabs the back buttons might influence each other in a multi-tab environment. 由于会话在所有选项卡中都相同,因此后退按钮可能会在多选项卡环境中相互影响。

If you want to use it: 如果你想使用它:

  • Add the plugin in bootstrap.php 在bootstrap.php中添加插件
  • Use the previous_page variable in your view (pass it to the back button) 在视图中使用previous_page变量(将其传递给后退按钮)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 $this-&gt;referer() 的 cakePHP 重定向无法正常工作 - cakePHP redirection with $this->referer() not working properly $ this-&gt; request-&gt; is(array(&#39;put&#39;))在cakephp框架中不起作用 - $this->request->is(array('put')) not working in cakephp framework $ this - &gt; _ request-&gt; isXmlHttpRequest()不工作 - $this->_request->isXmlHttpRequest() Not Working 修改CakePHP模型中的$ this-&gt; request-&gt; data? - Modify $this->request->data in model CakePHP? Cakephp $ this-&gt; request-&gt; params [&#39;pass&#39;] [0]是什么意思? - Cakephp what does $this->request->params['pass'][0] mean? 在不使用$ this-&gt; request-&gt; cakephp上的数据的情况下登录 - Auth login without use $this->request->data on cakephp 从$ this-&gt; request-&gt; data中提取正则表达式并存储在DB cakephp中 - extract regex from $this->request->data and store in DB cakephp 升级到 CakePHP 4.0 后 $this-&gt;request-&gt;getData() 为空 - $this->request->getData() empty after upgrade to CakePHP 4.0 $ han-3.2中的$ this-&gt; request-&gt; param()和$ this-&gt; request-&gt; post() - $this->request->param() and $this->request->post() in kohana 3.2 $ response = $ request-&gt; execute(); 工作不正常 - $response = $request->execute(); is not working properly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM