CodeIgniter redirect problem

#1
[eluser]Aerospace[/eluser]
When I go to http://www.hassanc.co.uk/home/ I get a 404 error. How can I make it so it redirects to http://www.hassanc.co.uk/home/index/ automatically? Is it something to do with the .htaccess file? Thanks for your help.

#2
[eluser]cahva[/eluser]
Userguide is your friend:
http://ellislab.com/codeigniter/user-gui.../urls.html

#3
[eluser]Aerospace[/eluser]
I've done that already, index.php is removed from the URL, which is great. But I want it to go to www.hassanc.co.uk/home/index automatically when someone visits my CodeIgniter root installation (www.hassanc.co.uk/home). Thanks

#4
[eluser]Suhas nazir[/eluser]
Hey u can simply remove index.php from ur url by using the following code.Copy the code and save it as .htaccess.Now u go to config.php and change it as $config['index_page'] = "";
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

#5
[eluser]Georgi Budinov[/eluser]
Guys he wants something else ... He managed to remove the index.php already ...

@Aerospace

Paste this in the constructor of your home controller and should be ok

Code:
if($this->uri->total_segments()==1)
{
    $this->load->helper('url');
    redirect(current_url().'/index');
}

#6
[eluser]Aerospace[/eluser]
[quote author="Georgi Budinov" date="1281731258"]Guys he wants something else ... He managed to remove the index.php already ...

@Aerospace

Paste this in the constructor of your home controller and should be ok

Code:
if($this->uri->total_segments()==1)
{
    $this->load->helper('url');
    redirect(current_url().'/index');
}
[/quote]

Now it goes to http://www.hassanc.co.uk/home/index/index Sad

I'm thinking about moving CodeIgniter to the root and then making a function called home() instead

But thanks for your help anyway Smile

#7
[eluser]Aerospace[/eluser]
Yes! I got it to work by defining the default controller as 'index' in config/routes.php
How do I mark this thread as 'solved'?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.