【问题标题】:Codeigniter error 404 on production after set_flashdata在 set_flashdata 之后的生产中出现 Codeigniter 错误 404
【发布时间】:2013-08-05 09:05:49
【问题描述】:

我在我的项目中使用 CI,当我在生产服务器上移动它时,我在调用 $this->session->set_flashdata 时看到错误“404 page not found”。当我请求任何页面时,此错误会保留,直到我清除 cookie。再次调用“set_flashdata”后,此错误重复出现。

function _set_success($message)
{
    $this->session->set_flashdata('is_db_msg', 1);
    $this->session->set_flashdata('db_msg', $message);;
}

$result = $this->page_model->edit_page($page_name, $this->_get_data_array());

$result ? $this->_set_success('OK') : $this->_set_error(DB_ERROR);

redirect(BASEURL.'admin/pages');

// 重定向后的服务器 404(在任何页面上)

BASEURL 是常量:DEFINE('http://mysite.com'); 我也在使用这个.htaccess:

DirectoryIndex index.php

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^(index\.php/?)?(.*[^/])/?$ http://mysite.com/$2 [L,R=301]

RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^$ http://mysite.com [L,R=301]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(index\.php/?)?(.+)/$ /$2 [L,R=301]

RewriteCond %{ENV:REDIRECT_FINISH} ^$
RewriteRule ^index\.php/(.*)$ $1 [L,R=301]


RewriteRule ^(main/index(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^([^/]*)/index/?$ $1 [L,R=301]

RewriteCond %{REQUEST_URI} ^(system|application).*
RewriteRule ^(.*)$ /index.php/$1 [L,E=FINISH:END] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,E=FINISH:END] 

请帮助并为我的英语不好感到抱歉。

【问题讨论】:

  • BASEURL 对我来说很安静。这是base_url() helper 的别名吗?
  • 不,它是常量 DEFINE('BASEURL','mysite.com')
  • 当然是这样。我的意思是为什么你需要一个方便的常量来定位你的 URL?为什么不使用 CI 内置助手?
  • 你应该尝试使用 redirect('admin/pages') 而不是 redirect(BASEURL.'admin/pages');

标签: codeigniter session


【解决方案1】:
You should use following for redirecting:

redirect('admin/pages');

or

redirect(base_url().'index.php/admin/pages');

or

DEFINE('BASEURL','http://mysite.com')
redirect(BASEURL.'index.php/admin/pages');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2017-09-03
    • 1970-01-01
    • 2018-06-09
    相关资源
    最近更新 更多