Remove index.php from URL in CodeIgniter 2
In CodeIgniter 2, removing the index.php from URLs requires a specific .htaccess configuration. However, some users have encountered issues when adapting .htaccess code from CodeIgniter 1.7 to 2.
Troubleshooting .htaccess Configuration
To resolve this problem, consider trying the following .htaccess code:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /(site)/ RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /(site)/index.php?/ [L] RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /(site)/index.php?/ [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /(site)/index.php?/ [L] </IfModule>
Replace "(site)" with the actual name of your site folder.
Additional Adjustments
In your index.php file, ensure that the following settings are configured correctly:
Updated Folder Structure
Note that if you have modified the default folder structure, adjust the paths accordingly:
To ensure proper functionality, make sure the paths in index.php accurately reflect these changes.
The above is the detailed content of How Can I Remove index.php from URLs in CodeIgniter 2 Using .htaccess?. For more information, please follow other related articles on the PHP Chinese website!