Setting a homepage |
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
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. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
@InsiteFX: My bad. Worked in CI 2, but apparently that where a bug so it got fixed.
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. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
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) |
Welcome Guest, Not a member yet? Register Sign In |