Skip to content
  • Homepage
  • HTML
  • CSS
  • Symfony
  • PHP
  • How to
  • Contact
  • Donate

Teach Developer

Articles, Guides & Tips

How to remove index.php from URL in CodeIgniter 4

Home  »  Codeigniter • HTML • PHP   »   How to remove index.php from URL in CodeIgniter 4
Posted on July 21, 2022July 24, 2022 5 Comments on How to remove index.php from URL in CodeIgniter 4
2,444

CodeIgniter 4 projects, you’ll notice that the URL has an extra argument. It is index.php in your project URL. So, if you don’t want this extra dimension you can remove it. This will create a clean URL for your website. There are several ways to remove this index.php in CodeIgniter 4. You can create a .htaccess file and create a rule to override URLs. It will require a host to access the .htaccess file it creates. So, it depends on a host like Apache or Nginx.

To remove the index.php in CodeIgniter 4, you must have an installed project. You can create a new one if you don’t have one.

How to Check index.php in URL
Firstly, I have opened the project inside the VS Code editor. I already started my development server by hitting the spark command.

php spark serve

Now, you can see here, that the development server is started on http//localhost:8080.

Remove index.php in CodeIgniter 4

Now, come back to the CodeIgniter 4 project. Firstly, go to the app/Config/App.php. You will see the baseURL of the project.

If you want to change the base URL of the CodeIgniter 4 project then you can change it from here.

In the next line, you will see the Index File description. So, you already noticed one thing while accessing the homepage of CodeIgniter. In the index page property by default, the index.php was added.

Config/App.php in CodeIgniter 4

Here, I haven’t changed the base URL. I will access it on the default port by running the application through the spark command. So, I just removed the index.php from the index page.

Removed index.php From the Config in CodeIgniter 4

CodeIgniter 4 project has by default a .htaccess file in the public folder. So, no need to create another .htaccess file.

.htaccess file in CodeIgniter 4

Now, index.php is Removed From URL in CodeIgniter 4

Conclusion

Finally, we removed the index.php from the URL of the CodeIgniter 4 application. Now, the URL became neat and clean. So, you can create routes and everything will work perfectly. I hope this tutorial will help you.

Codeigniter, HTML, PHP

Post navigation

Previous Post: How To Install Nginx, PHP on Ubuntu 22.04
Next Post: How to use setTimeout and setInterval methods in JavaScript

Related Posts

  • How to Send Email from Localhost in PHP
  • HTML Basic Examples
  • How to PHP Get Max Value From Array
  • How to use events listeners and Event Subscriber in Symfony
  • Common Mistakes with Conditionals
  • HTML Tutorial

5 Comments on “How to remove index.php from URL in CodeIgniter 4”

  1. Kyoung-Rok Jan says:
    July 22, 2022 at 11:54 am

    Great article. Thanks!

    Reply
  2. Jack says:
    July 22, 2022 at 11:56 am

    Thanks & Good Codeigniter information provide.

    Reply
  3. Lucashmsilva says:
    July 24, 2022 at 6:38 am

    “Great content as always! Thanks a lot.”

    Reply
  4. Rakibul Haq says:
    July 24, 2022 at 6:43 am

    “This is what exactly I was looking for🙏
    Thanks a lot buddy for sharing.,its really easy to understand and implement.”

    Reply
  5. Alex Xu says:
    July 24, 2022 at 6:48 am

    Very detailed explanation. Thanks for sharing it.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Codeigniter (3)
  • CSS (11)
  • eCommerce (1)
  • Framework (1)
  • Git (3)
  • How to (43)
  • HTML (5)
  • JavaScript (15)
  • Jquery (7)
  • Laravel (1)
  • Linux (4)
  • Magento-2 (1)
  • Node js (4)
  • Others (2)
  • PHP (11)
  • React (13)
  • Server (1)
  • SSH (3)
  • Symfony (6)
  • Tips (16)
  • Top Tutorials (10)
  • Ubuntu (3)
  • Vue (1)
  • Wordpress (7)

Latest Posts

  • What is SSH in Linux?
  • How to Delete Files in Ubuntu Command Line
  • How to Deploy a React application on a cPanel
  • How to use events listeners and Event Subscriber in Symfony
  • How to Convert PHP CSV to JSON

WEEKLY TAGS

AJAX (1) Codeigniter (1) Javascript (11) JQuery (1) PHP (16) Programming (1) React (3) Symfony (1)

Random Post

PHP 8.1: read-only properties
How to Deploy a React application on a cPanel
How to Create Live Search in HTML table with jQuery
How to Get Environment Variables in Laravel ReactJS
How to use setTimeout and setInterval methods in JavaScript

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved