Welcome Guest, Not a member yet? Register   Sign In
redirect not working
#1

Hi,
my redirect function to admin dashboard is not working but it was working yesterday i have tried every thing in .htaccess and config and route files i dont know what to do?
is it need to update codeigniter ?
Reply
#2

There must be some kind of change on your script/server so something working yesterday not to work today.
How ever if you want help you have to show us your code where the bug is coming out else how the hell we can know what is causing it ?
Best VPS Hosting : Digital Ocean
Reply
#3

this is my htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|img|js|sexyimages|media|roleimages|lang|uploads|files|profile|audio|video|videoplayer|talentimages|captcha|gmap|timthumb|include|ckeditor|webfonts|player|robots\.txt|css|sitemap\.xml|sitemap\.html|BingSiteAuth\.xml)
RewriteRule ^(.*)$ ./index.php/$1 [L]

</IfModule>

and this is my admin login code
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {



function __construct()
{
// Call the Model constructor
parent::__construct();
$this->load->model('admin/adminloginmodel','', TRUE);
$this->load->library('session');
}

public function index()
{
//$objResponse=new xajaxResponse();
$this->load->helper('url');
$data['msg']= '';
if(isset($_POST['submit']))
{

$msg=$this->adminloginmodel->check_adminlogin();
//echo $msg;
if($msg != 'success')
{
//redirect('admin/dashboard', 'refresh');
$data['msg']= $msg;
}
else
{
redirect(site_url('admin/dashboard'));

}

}

$this->load->view('admin/adminhome_view',$data);
}
}

/* End of file home.php */
/* Location: ./application/controllers/home.php */
Reply
#4

(This post was last modified: 12-08-2014, 04:45 AM by InsiteFX.)

Code:
<IfModule mod_rewrite.c>

    # Make sure directory listing is disabled
    Options +FollowSymLinks -Indexes
    RewriteEngine on

    # NOTICE: If you get a 404 play with combinations of the following commented out lines
    #AllowOverride All
    #RewriteBase /wherever/ci/is
    RewriteBase /

    # Send request via index.php (again, not if its a real file or folder)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond $1 ^(robots\.txt|favicon\.ico|style\.css)

    # deal with php5-cgi first
    <IfModule mod_fcgid.c>
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>

    <IfModule !mod_fcgid.c>

        # for normal Apache installations
        <IfModule mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [QSA,L]
        </IfModule>

        # for Apache FCGI installations
        <IfModule !mod_php5.c>
            RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
        </IfModule>

    </IfModule>

</IfModule>
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

i tried your code its now showing 404 not found error
before it was loading the admin login form
but the redirecting to dashboard after that showing empty page
actually all login forms not working on the website
Reply
#6

i see that your redirect is commented


PHP Code:
//redirect('admin/dashboard', 'refresh'); 



maybe that is the problem?
Reply
#7

I tried that also still not working Sad
Reply
#8

(12-08-2014, 01:09 PM)hadeel Wrote: I tried that also still not working Sad

Replace this in your controller

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Home extends CI_Controller {


    public function 
__construct()
    {
        
// Call the Model constructor
        
parent::__construct();
        
$this->load->model('admin/adminloginmodel');

        
// Load your helpers / drivers / libraries globaly from the autoload.php file. You will need them across you app, not just here.
        
$this->load->library('session');
        
$this->load->helper('url');
    }

    public function 
index()
    {
        
//$objResponse=new xajaxResponse();
        
$data['msg']= '';

        if(isset(
$_POST['submit']))
        {
            
$msg=$this->adminloginmodel->check_adminlogin();
            
//echo $msg;
            
if($msg != 'success')
            {
                
$data['msg']= $msg;
                
redirect('admin/dashboard''refresh');

            } else {
                
redirect('admin/dashboard');
            }
        }
        
$this->load->view('admin/adminhome_view',$data);
    }


}
/* End of file home.php */
/* Location: ./application/controllers/home.php */ 


And this in your .htaccess file


Code:
<IfModule mod_rewrite.c>

 Options +FollowSymLinks
 RewriteEngine on

 # Send request via index.php
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteCond $1 ^(robots\.txt|favicon\.ico|style\.css)

   # deal with php5-cgi first
   <IfModule mod_fcgid.c>
       RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
   </IfModule>

   <IfModule !mod_fcgid.c>
       # for normal Apache installations
       <IfModule mod_php5.c>
           RewriteRule ^(.*)$ index.php/$1 [QSA,L]
       </IfModule>

       # for Apache FCGI installations
       <IfModule !mod_php5.c>
           RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
       </IfModule>
   </IfModule>

</IfModule>
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Reply
#9

i have tried your code still same problem and if changed the .htaccess all pages will be not working
Reply
#10

For a redirect on your own server you dont need a url function. just write it in that way

PHP Code:
old code
redirect
(site_url('admin/dashboard'));

new 
code
redirect
('admin/dashboard'); 

In your /application/controllers you must hava a Admin.php with a dashboard method.

Reply




Theme © iAndrew 2016 - Forum software by © MyBB