The following code is in my .httaccess file.
#write your project folder name as rewritebase
RewriteBase /Codeignitor3D/
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*) index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?/$1 [L]
It's give the 500 internal server error
Try this Rule:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
In your config.php
file,
//Find
$config['index_page'] = "index.php"
//and replace it with
$config['index_page'] = ""
Steps to remove index.php from url codeigniter:
Config changes: Go to “application/config/config.php”
Find below code:
$config['index_page'] = 'index.php';
Replace with the below code:
$config['index_page'] = '';
.htaccess changes: If you not have any htaccess create new and place it on your root.
Note: if you have codeigniter in subdirectory change RewriteBase / to RewriteBase /subdir/
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Now open your site pages you will found clean url with no index.php. so your all url looks like http://example.com/controller/method. Now any of HTTP request for index.php will be treated as a request for your index.php file.
If still issue: Need to apply one more config changes.
Go to “application/config/config.php”
Find below code
$config['uri_protocol'] = 'AUTO';
Replace with the below code
$config['uri_protocol'] = 'REQUEST_URI';
Now you have fully done to remove index.php from url codeigniter and getting clean url in codeigniter.
- Make sure mod_rewrite is installed and enabled
- Make sure apache's site config file allows the use of .htaccess
- Check apache's error log as well as PHP's error log, since you are getting 500
Review http://www.codeigniter.com/user_guide/general/urls.html