Posted by Ridwan Fadilah on Jun 16, 2020 - 09:00 pm
a simple way to set the default page, removing public and index from the URL in CodeIgniter 4
CodeIgniter is one of the PHP framework that can help your work. That's the first what I feel when using this framework. CodeIgniter can make a program more efficient, is like a bootstrap when you work with CSS. This tutorial will show you how to set the default page in CodeIgniter. It's the first step when we use CodeIgniter.
The first must to do is make sure you have open your project directory in your code editor.
After that, open the public folder in your file explorer. In this folder, you'll find the
index.php file and the
.htaccess file. Copy the file and paste it in your root directory.
Back to your code editor, open the
app.php in the config folder. Find the
$baseURL variable and change the URL to your project name URL.
If you're using mod_rewrite to remove the page, set the
$indexPage variable so that it is blank.
Same as the
$baseURL you need to change the
Save the configuration, and then open the
index.php from your root directory. Change the
Save all changes and try to load your page in your browser.
After removing the
index from the URL, let's start to set the default page of your web.
With CodeIgniter, it's so easy to set the default page. We only need to change some configuration in CodeIgniter.
First, open the
app/view/ folder and make a new folder named as
home or whatever you want. After that, create a new file and give the name
index.php in your home folder.
Now you can put anything to your
index.php file such as HTML element for the home page.
For the last step, open the
Controllers folder, remove the
('welcome_message') and replace with
home/index defines the
home folder and
That's the way to set the default page of your website in CodeIgniter 4. If you don't understand this article, you can see the video of this tutorial on my YouTube Channel.
Thank's for reading this tutorial.