Welcome Guest, Not a member yet? Register   Sign In
How to make mysite.com forward to mysite.com/home?
#1

[eluser]welzie[/eluser]
This is probably a really dumb question, but I am new to PHP and CI.

How do I make requests for mysite.com be automatically directed to mysite.com/home? Below is what my .htaccess looks like. Notice I renamed index.php to controller.php.

Code:
<IfModule mod_rewrite.c>    
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ test/controller.php/$1 [L]
</IfModule>
#2

[eluser]Michael Ekoka[/eluser]
I'd like to help, but i'll probably need to better understand what exactly you're trying to do.

You're giving us mysite.com -> mysite.com/home, which could imply either a url redirect (send an instruction to redirect the browser to mysite.com/home), or a controller rerouting (keep the browser pointed at url mysite.com but internally route it to the home controller).

At the same time you're giving us a mod_rewrite rule that implies an internal server redirect of the request (grab any incoming requests, but begin processing them at test/controller.php).

Could you describe in more details the behavior that you're trying to reproduce?
#3

[eluser]welzie[/eluser]
I want the second option you mentioned. Re route the incoming request to the home.php controller. The url doesn't have to still say mysite.com it can have the controller name in the path like mysite.com/home. I'm just having trouble figuring out how to get CI to show my home page when the root directory is requested.

Do I add an exception in htaccess for a index.php and have the index.php file redirect to mysite.com/home?

Or this there a way to get CI to re route to a "default" page when no controller is in the url?

thx for the help
#4

[eluser]John Fuller[/eluser]
Just set your default controller to the "home" controller.

http://ellislab.com/codeigniter/user-gui...ml#default




Theme © iAndrew 2016 - Forum software by © MyBB