CodeIgniter Forums
Redirect without index.php being prepended - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Redirect without index.php being prepended (/showthread.php?tid=40168)



Redirect without index.php being prepended - El Forum - 03-31-2011

[eluser]domainsvault[/eluser]
Ok, I have several cases where I am using redirect() or equivilant with javascript [removed]() either way.. when this occurs my url goes from

domain.com/login
to
domain.com/index.php/home

(example of use from a login page to the home page) is there a way to redirect() or point with javascript (which ever case is the serving point at the time) to not have it automaticly add index.php to the URL currently I am using .htaccess to avoid the index.php being in the URL like that

i am redirecting usually like this

redirect('./') to go back to the main page from where ever..
reditrec('./home') when I am being specific


Redirect without index.php being prepended - El Forum - 03-31-2011

[eluser]xerobytez[/eluser]
If you are using .htaccess to remove index.php then you should open up /application/config/config.php and change

Code:
$config['index_page'] = 'index.php';

to:

Code:
$config['index_page'] = '';

Another option would be to use the base_url(); function which gives the base path to your site. So you could do
Code:
<a href="&lt;?php echo base_url(); ?&gt;login">Login</a>
to point to http://yoursite.com/login

Good luck


Redirect without index.php being prepended - El Forum - 03-31-2011

[eluser]Alias M2K[/eluser]
I think your problem is solved in the documentation. Smile
Check out the heading: Removing the index.php file here: CodeIgniter User Guide