Welcome Guest, Not a member yet? Register   Sign In
Redirection increase the length of my URL
#1

[eluser]dunicorn[/eluser]
I wrote a function in my controller like this

Code:
function index(){
   $this->load->helper(array("form","url"));
   redirect("?ref=main","refresh");
}

.... On redirection, it adds
Quote:/index.php?ref=main
to the current URL, such that if i have l
Quote:ocalhost/abc/index.php?ref=home
, the new URL will be
Quote:localhost/abc/index.php/index.php?ref=main.

What's wrong???
#2

[eluser]smilie[/eluser]
Not tested, but try:

redirect(site_url('index.php/')."?ref=main","refresh");

Cheers,
Smilie
#3

[eluser]dunicorn[/eluser]
smille .... Not working ... it's even worse adding like three "/index.php" ...
#4

[eluser]OES[/eluser]
Smile was close try

redirect(site_url() . ”?ref=main”,“refresh”);
#5

[eluser]dunicorn[/eluser]
no improvement .... OES ... adding more "index.php". Need this urgently..... helppppp.
#6

[eluser]OES[/eluser]
Ok then try with base_url()

redirect(base_url() . ”?ref=main”,“refresh”);
#7

[eluser]dunicorn[/eluser]
Not working still ....
#8

[eluser]tonanbarbarian[/eluser]
2 questions

1. what is your base_url in the config?

2. can you explain a bit about why you are trying to do this. there may be a better way of doiing what you need without adding ?ref=main to the url, which is not standard CI url and could be causing the issue
#9

[eluser]dunicorn[/eluser]
this is part of my config.php
Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://example.com/
|
*/
$server = "http://localhost/skillbase";
$config['base']    = "$server";
$config['images']= "$server/images";
$config['styles']= "$server/styles";
$config['scripts']= "$server/scripts";
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "index.php";
$config['enable_query_strings'] = TRUE;
$config['controller_trigger']     = 'ref';
$config['function_trigger']     = 'mm';
$config['directory_trigger']     = 'd'; // experimental not currently in use

All I want to do is simple .... i have a login and logout controller ... after logging in, I want the controller to redirect to the main page and logging out should take me to the home page.

To log in ... this is the index function of the controller
Code:
function index() {
        if ($this->user->auth($_POST)) {
            redirect("?ref=main", "refresh");
        } else {
            redirect("?ref=home", "refresh");
        }
    }

To logout ... this is the index function of the controller
Code:
$this->user->logout();
        $this->load->helper(array("form","url"));
        redirect("?ref=home","refresh");

Although the redirection worked, but the url on the browser is getting longer and longer .... if i keep logging in and logging out ....

HELP!!!!
#10

[eluser]smilie[/eluser]
What is the url once you log in and log out succesfully?

Cheers,
Smilie




Theme © iAndrew 2016 - Forum software by © MyBB