Removing "index.php" from CodeIgniter URLs
In CodeIgniter, by default, URLs include the "index.php" segment, leading to less appealing and verbose URLs. This can be easily rectified to achieve a more streamlined and intuitive user experience.
Apache Configuration with .htaccess
For Apache web servers, create a ".htaccess" file within the root web directory and include the following code:
RewriteEngine on RewriteCond !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt) RewriteRule ^(.*)$ /index.php/ [L]
This code instructs the server to rewrite URLs that do not match specific exceptions, such as "index.php" or static files (e.g., JavaScript, CSS, images), and redirect them through the "index.php" file with the matching segment appended.
Alternative Approach
An alternative configuration approach is provided in the following URL:
[CodeIgniter .htaccess Configuration](http://snipplr.com/view/5966/codeigniter-htaccess/)
The above is the detailed content of How Can I Remove 'index.php' from CodeIgniter URLs?. For more information, please follow other related articles on the PHP Chinese website!