Setting a homepage - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Setting a homepage (/showthread.php?tid=70350) |
Setting a homepage - TamasD - 03-28-2018 Hi, I organized my controllers and views into subdirectories like this frontend admin I created a Home.php in controllers/frontend and a home.php file in views/frontend CI is installed in http://localhost/ci when I access this url I'd like the home view to load, but currently I can only access it via http://localhost:8080/ci/frontend/home I'm guessing it may have something to do with my .htaccess file which is this: Code: RewriteEngine On What am I doing wrong? Thanks RE: Setting a homepage - jreklund - 03-28-2018 application\routes.php $route['default_controller'] = 'frontend/home'; RE: Setting a homepage - TamasD - 03-28-2018 (03-28-2018, 02:09 PM)jreklund Wrote: application\routes.php Yeah, I already set this, but it's still not working. RE: Setting a homepage - InsiteFX - 03-28-2018 The default controller cannot be in a sub-directory. From the CodeIgniter Users Guide. You can NOT use a directory as a part of this setting! PHP Code: <?php Use the above and then create a Home controller. PHP Code: <?php Hope that helps. RE: Setting a homepage - jreklund - 03-28-2018 @InsiteFX: My bad. Worked in CI 2, but apparently that where a bug so it got fixed. RE: Setting a homepage - InsiteFX - 03-28-2018 Right, they fixed users were abusing it in version 2. I just make a MY_Controller that has a BaseController then I extented that into a Backend and Frontend controller. Backend for Admin area and Frontend for the public area. As for the admin I use an Admin directory under controllers and make views with directories. RE: Setting a homepage - XtreemDeveloper - 03-29-2018 Replace your .htaccess code by this. RewriteEngine On RewriteBase /ci/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] Replace base_url in config.php file $config['base_url'] = 'http://127.0 0.1/ci/'; $config['index_page'] = ''; Use home controller code <?php /* Welcome controller for front */ defined('BASEPATH') OR exit('No direct script access allowed'); class Home extends CI_Controller { function __construct() { Parent::__construct(); } function index() { $this->load->view('front/frontend/home'); } } browser url: http://127.0 0.1/ci/frontend/home By:Xtreem Solution [Highly Skilled Laravel Developer](https://xtreemsolution.com/hire-laravel-developer.html) [Dedicated PHP Developer](https://xtreemsolution.com/hire-php-developer.html) |