Welcome Guest, Not a member yet? Register   Sign In
redirect() ignores my .htaccess and uses domain_name/index.php/<redirected_url>
#1

[eluser]Unknown[/eluser]
I'm new to codeigniter. My url's are working properly, aka trunk.dev/login/ Till I began working on the login/authentication for my application. When I call the redirect() function to redirect when authentication fails it redirects properly but uses the index.php so my url address points to -> http://trunk.dev/index.php/login instead of trunk.dev/login/

Any thoughts?

Below are my settings.

.htaccess
Code:
RewriteEngine On
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]


apache-conf
Code:
<VirtualHost 127.0.0.1:80>
   ServerAdmin [email protected]
   DocumentRoot "/www/project"
   ServerName trunk.dev
   <Directory '/www/project'>
        Options All
        AllowOverride All
   </Directory>
   ServerAlias www.trunk.dev
   ErrorLog "/private/var/log/apache2/trunk-error_log"
</VirtualHost>

lastly, my code calling the function
Code:
$handshake = $this->User_model->authenticate($email, $password);
if(!empty($handshake)){
   //authentication success
   redirect('user/', 'location');
} else {
   //throw error because authentication failed and redirect user to loginForm
   redirect('login/', 'location');
}
#2

[eluser]Pascal Kriete[/eluser]
Go into application/config/config.php and blank out the index page config value:
Code:
// Old
$config['index_page'] = "index.php";

// New
$config['index_page'] = "";

CI uses that to create urls when you're using site_url, redirect, anchor, form_open and other functions that generate urls.

Welcome to CodeIgniter.
#3

[eluser]Unknown[/eluser]
thanks that did the trick. not sure if my documentation for the url rewriting mentioned to go into my config file and remove that string. non eht less thanks for the quick answer. Saves me lots of time. Awesome!
#4

[eluser]hugle[/eluser]
[quote author="Pascal Kriete" date="1223881764"]Go into application/config/config.php and blank out the index page config value:
Code:
// Old
$config['index_page'] = "index.php";

// New
$config['index_page'] = "";

CI uses that to create urls when you're using site_url, redirect, anchor, form_open and other functions that generate urls.

Welcome to CodeIgniter.[/quote]

thank you!
couldn't think that can be so easy!




Theme © iAndrew 2016 - Forum software by © MyBB