Home > Backend Development > PHP Tutorial > How Can I Remove the 'index.php' from CodeIgniter URLs?

How Can I Remove the 'index.php' from CodeIgniter URLs?

Susan Sarandon
Release: 2024-12-18 18:28:20
Original
145 people have browsed it

How Can I Remove the

Eliminating the Ubiquitous "index.php" in CodeIgniter Routes

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]
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template