How to display site homepage using http://localhost/ci instead of http://localhost/ci/welcome |
[eluser]developer86[/eluser]
Hello good people, I am new to codeigniter and i'm urgently looking for help with loading a website homepage without entering any controller name in my URL input. For example, when i enter http://localhost/ci/ in my web browser, i want to see the homepage (main page) loaded at http://localhost/ci/welcome but instead it returns all directories in the index of /ci. This is the problem i have and i've been trying hard to resolve it without any luck. Currently, i'm able to successfully load the homepage URL with any of the options below: http://localhost/ci/welcome http://localhost/ci/welcome/index http://localhost/ci/index.php Please refer to the steps below that i took to remove index.php from my URLs 1. Config file (application/config/config.php) edited to show the following; Code: $config['base_url'] = ''; Code: $config['index_page'] = ''; 2. application/config/routes.php still points to welcome controller Code: $route['default_controller'] = "welcome"; 3. created a .htaccess file with the following rules; Code: <IfModule mod_rewrite.c> Please help me fix this
[eluser]Karman de Lange[/eluser]
Is your web server setup to run index.php as default document? see : http://stackoverflow.com/questions/23844...by-default
[eluser]developer86[/eluser]
[quote author="Karman de Lange" date="1387802968"]Is your web server setup to run index.php as default document? see : http://stackoverflow.com/questions/23844...by-default[/quote] Hi Karman, thank you for your post. index.php was not setup as the default document in my web server (Apache 2.4.7). Instead, index.html was setup in the server configuration file httpd.conf by default. . After adding index.php to my .htaccess file, i successfully launched my home page at http://localhost/ci. The updated .htaccess file now contains the following line at the top and the rest of its contents are the same; Code: DirectoryIndex index.php I really appreciate your support and direction. Everything is working according to my expectations !
[eluser]developer86[/eluser]
[quote author="Tpojka" date="1387803559"]Try this one.[/quote] Thanks for the link. I found it useful but i already got a solution to the same problem.
[eluser]Tpojka[/eluser]
Also, regarding user guide, you should make this change too: Code: $config['base_url'] = 'http://localhost/ci/';
[eluser]developer86[/eluser]
[quote author="Tpojka" date="1387930206"]Also, regarding user guide, you should make this change too: Code: $config['base_url'] = 'http://localhost/ci/'; Is it a best practice rule ? My understanding has been that if base_url is not set, codeigniter will automatically find it. Otherwise, i have set it up now. Thanks again for your support.
[eluser]Tpojka[/eluser]
I am setting base URL all the time. And don't forget trailing slash on it because of future code collision. CI is meant to use it with trailing slash set - there is explanation in config.php too.
|
Welcome Guest, Not a member yet? Register Sign In |