CodeIgniter .htaccess Generator
Remove index.php and enable clean URLs in CodeIgniter.
Version Check!
This generator works for both CodeIgniter 3 (root folder) and CodeIgniter 4 (public folder). Check your version before uploading.Clean URL .htaccess for CodeIgniter
Why CodeIgniter needs a .htaccess?
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.
Who should use this?
Developers who want to remove index.php from their URLs and secure their framework folders from direct access.
When NOT to use this?
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.
Plain-English Explanation
RewriteRule ^(.*)$ index.php/$1
Framework CriticalThe "Magic" line. It takes whatever you typed in the URL and quietly sends it to index.php so CodeIgniter can process it.
RedirectMatch 403 ^/(system|application)/
Security RecommendedTells the server: "If someone tries to browse the system or application folders directly, show them a 403 Forbidden error."
RewriteBase /
CompatibilityEnsures the rewrite rules start from the root of your domain. Helpful on some shared hosting environments.
Frequently Asked Questions (FAQs)
.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.
-
Forgetting RewriteBase:
If your site runs inside a subfolder (for example,
example.com/blog/), you must setRewriteBase /blog/. -
AllowOverride disabled:
If your hosting provider does not allow
.htaccessoverrides, rewrite rules will be ignored entirely. -
Case sensitivity issues:
On Linux servers,
Index.phpandindex.phpare 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.