My redirect function is not working in codeigniter?

回眸只為那壹抹淺笑 提交于 2019-12-25 03:12:42

问题


I have the following code:

$this->video->videoupdate($userid, $title, $id);
redirect("admin/videos", "refresh");

But the redirect is not working and I don't know why (I am using CodeIgniter)


回答1:


Have you sent anything to the browser prior to calling redirect? From the user guide

Note: In order for this function to work it must be used before anything is outputted to the browser since it utilizes server headers.




回答2:


have you loaded the URL helper?

$this->load->helper('url');

Load this in your controller. I usually put mine either in the constructor or the autoload config.




回答3:


try this :

redirect("admin/videos");

without "refresh"




回答4:


  1. Remove the echo if any above redirect
  2. Check your htaccess, write like this:

    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
    RewriteBase /sitename/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d``
    RewriteRule ^(.*)$ /index.php [L]
    



回答5:


I have just fixed it with this ->

$config['base_url'] = 'http://localhost:3000/';

So apparently you must define this before use your url helper.



来源:https://stackoverflow.com/questions/4817482/my-redirect-function-is-not-working-in-codeigniter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!