views:

6878

answers:

3

can anyone tell me why my redirect helper doesn't work the way i'd expect. i'm trying to redirect to the index method of my main controller like so:

if($provider == '') {
    redirect('/index/provider1/', 'location');
}

but that takes me www.mysite.com/index/provider1/ when it should go to www.mysite.com/provider1.

does that make sense can anyone give any advice? this is what my htaccess looks like and i have index_page in config set to blank, although i don't think that the issue is htaccess here it is in case:

RewriteEngine on

RewriteCond %{REQUEST_URI} !^(index\.php|files|images|js|css|robots\.txt|favicon\.ico)

RewriteCond %{HTTP_HOST} ^mysite.com/ttnf/
RewriteRule (.*) http://www.mysite.com/ttnf/$1 [R=301,L]

RewriteBase /ttnf/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

php_flag display_errors On
A: 

DUH....

i'm an idiot today, i wasn't sending it to my controller (which is main.php) instead it was as if i was trying to load a controller named index. so sorry.

ocergynohtna
This was prolly down-voted because it's not correct practice for posting your solution in StackOverflow. But I appreciate the update and as a CI noob it was actually a bit of help.
Smandoli
+4  A: 

redirect()

URL Helper


The redirect statement in code igniter sends the user to the specified web page using a redirect header statement.

This statement resides in the URL helper which is loaded in the following way:

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

The redirect function loads a local URI specified in the first parameter of the function call and built using the options specified in your config file.

The second parameter allows the developer to use different HTTP commands to perform the redirect "location" or "refresh".

According to the Code Igniter documentation: "Location is faster, but on Windows servers it can sometimes be a problem."

Example:

if ($user_logged_in === FALSE)
{
     redirect('/account/login', 'refresh');
}
Jon Winstanley
A: 

I have a similar problem, but I get a 500 error... apache config?

Gerardo Jaramillo