Removing index.php from URLs in Codeigniter 2
Many developers have encountered difficulties removing index.php from URLs in Codeigniter 2. While solutions from Codeigniter 1.7 may not be applicable, there are specific steps you can take to achieve this.
Solution:
To remove index.php from URLs in Codeigniter 2, try the following:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /(site)/ RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/ [L] RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.php?/ [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/ [L] </IfModule>
Explanation:
This updated code block modifies the RewriteBase directive to include your site folder's name, which is assumed to be "(site)" in this example. By specifying the correct site folder, the server will be directed to the appropriate location to search for the index.php file when requested.
The above is the detailed content of How to Remove index.php from URLs in CodeIgniter 2?. For more information, please follow other related articles on the PHP Chinese website!