Remove index.php and enable clean URLs in CodeIgniter.
By default, CodeIgniter requires index.php to be present in all your URLs (e.g., example.com/index.php/welcome). The .htaccess file uses Apache's rewrite engine to hide it, giving you professional-looking URLs like example.com/welcome.
Developers who want to remove index.php from their URLs and secure their framework folders from direct access.
If you have already configured uri_protocol in your config.php to something that doesn't support query strings or if you are using Nginx.
The "Magic" line. It takes whatever you typed in the URL and quietly sends it to index.php so CodeIgniter can process it.
Tells the server: "If someone tries to browse the system or application folders directly, show them a 403 Forbidden error."
Ensures the rewrite rules start from the root of your domain. Helpful on some shared hosting environments.
.htaccess file in the same directory
as index.php (the project root).
For CodeIgniter 4, it should be placed inside the /public folder.
.htaccess rules, you must update your CodeIgniter configuration.
For CodeIgniter 3, set
$config['index_page'] = '';
inside application/config/config.php.
This allows clean URLs without index.php.
base_url is set correctly in the configuration file.
Also verify that your controllers and routes are correctly defined,
as rewrite rules alone cannot fix routing misconfigurations.
example.com/blog/),
you must set RewriteBase /blog/.
.htaccess overrides,
rewrite rules will be ignored entirely.
Index.php and index.php are different.
Always use lowercase file names.
.htaccess rules.
If clean URLs do not work, contact your hosting provider
to confirm that mod_rewrite and AllowOverride are enabled.