The unsightly "index.php" tacked onto every URL path in CodeIgniter can be a persistent annoyance. Fortunately, it can be swiftly removed, leaving you with clean, professional-looking URLs.
For Apache users, a simple .htaccess file placed in the root web directory can do the trick:
RewriteEngine on RewriteCond !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt) RewriteRule ^(.*)$ /index.php/ [L]
This code ensures that all incoming requests except those containing specific extensions (such as .js, .css, .jpg) or specific file names (like robots.txt) are rewritten to include "index.php".
Another robust solution can be found at:
http://snipplr.com/view/5966/codeigniter-htaccess/
By implementing these modifications, you can banish the pesky "index.php" from your URLs, enhancing both the aesthetics and functionality of your CodeIgniter application.
The above is the detailed content of How Can I Remove the 'index.php' from CodeIgniter URLs?. For more information, please follow other related articles on the PHP Chinese website!