I've seen plenty of write-ups on how to remove index.php from your URL. What these write-ups don't seem to account for is if you're working on a WAMP server.
So here are the steps to remove index.php using .htaccess
Step 1
Open application/config.php
$config['index_page'] = "index.php"
needs to be
$config['index_page'] = ""
You may also have to change
$config['uri_protocol'] = "AUTO"
to
$config['uri_protocol'] = "REQUEST_URI"
You might also have to clear your base_url
$config['base_url'] = ""
Step 2
Create a .htaccess file in your CodeIgniter root directory (the directory where you see your application, assets, system folders and add the following code to your .htaccess file:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>
If you're not running WAMP, Step 2 should be your last step. Just save and test.
If you are using WAMP, then you have to do Step 3
Step 3
It does not work in WAMP because rewrite_module by default is disabled so we need to enable it.
1) Left click the WAMP icon
2) Apache
3) Apache Modules
4) Left click rewrite_module
5) Restart All Services.
So here are the steps to remove index.php using .htaccess
Step 1
Open application/config.php
$config['index_page'] = "index.php"
needs to be
$config['index_page'] = ""
You may also have to change
$config['uri_protocol'] = "AUTO"
to
$config['uri_protocol'] = "REQUEST_URI"
You might also have to clear your base_url
$config['base_url'] = ""
Step 2
Create a .htaccess file in your CodeIgniter root directory (the directory where you see your application, assets, system folders and add the following code to your .htaccess file:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>
If you're not running WAMP, Step 2 should be your last step. Just save and test.
If you are using WAMP, then you have to do Step 3
Step 3
It does not work in WAMP because rewrite_module by default is disabled so we need to enable it.
1) Left click the WAMP icon
2) Apache
3) Apache Modules
4) Left click rewrite_module
5) Restart All Services.
Comments
Post a Comment