Removing "index.php" from CodeIgniter URLs
The "index.php" segment that appears in URLs when using CodeIgniter can be distracting and undesirable. To eliminate this and achieve clean, non-index.php-fied URLs, follow these steps:
1. Create an .htaccess file.
Place an .htaccess file in your root web directory.
2. Add the following code to .htaccess:
Use the following code block in your .htaccess file:
RewriteEngine on RewriteCond !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt) RewriteRule ^(.*)$ /index.php/ [L]
3. Customize the .htaccess file (optional).
If necessary, modify the file to include any specific JavaScript, CSS, or image root folder names that may need to be excluded from the rewrite rule.
Alternative .htaccess Configuration:
You may also use an alternative .htaccess configuration located here: http://snipplr.com/view/5966/codeigniter-htaccess/. This configuration includes additional handling for domain base URLs and may be suitable depending on your specific needs.
The above is the detailed content of How Do I Remove 'index.php' from My CodeIgniter URLs?. For more information, please follow other related articles on the PHP Chinese website!