Redirect with CodeIgniter
Asked 07 September, 2021
Viewed 1.2K times
  • 52
Votes

Can anyone tell me why my redirect helper does not work the way I'd expect it to? I'm trying to redirect to the index method of my main controller, but it takes me www.mysite.com/index/provider1/ when it should route to www.mysite.com/provider1. Does this make sense to anyone? I have index page in config set to blank, although I don't think that it is the issue. Does anyone have advice on how to fix this issue? Thanks in advance!

Controller:

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

.htaccess:

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

5 Answer