my website is working with and with out index.php but i just want to open url without index.php. i did exactly as asked in the documentation of codeigniter, created new file .htaccess i want to remove index.php from my url or redirect to the url where is no index.php include.
Step:-1 Open the folder “application/config” and open the file “config.php“. find and replace the below code in config.php file.
//find the below code
$config['index_page'] = "index.php"
//replace with the below code
$config['index_page'] = ""
Step:-2 Go to your CodeIgniter folder and create .htaccess
Path:
Your_website_folder/
application/
assets/
system/
.htaccess <——— this file
index.php
Step:-3 Write below code in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Step:-4 In some case the default setting for uri_protocol does not work properly. To solve this problem just open the file “application/config/config.php“, then find and replace the below code
//find the below code
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI"
That's all but in wamp server, it does not work because rewrite_module by default disabled so we have need to enable it. for this do the following
1) Left click WAMP icon
2) Apache
3) Apache Modules
4) Left click rewrite_module
- 6 years ago
Add this code to your .htaccss file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /testproject/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hot Questions