My current urls look like this [mysite]index.php/[rest of the slug]
.
I want to strip index.php
from these urls.
mod_rewrite
Removing index.php from url of codeigniter
Three steps are require to remove index.php from url in Codeigniter.
1)Create .htacess file in parallel to application holder and just copy past the following code:
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2) Change $config['index_page'] to blank in config.php in application folder as below:
$config['index_page'] = '';
3) Enable “rewrite_module” of apache.
Follow these step your problem will be solved
1- Download .htaccess file from here https://www.dropbox.com/s/tupcu1ctkb8pmmd/.htaccess?dl=0
2- Change the CodeIgnitor directory name on Line #5. like my directory name is abc (add your name)
3- Save .htaccess file on main directory (abc) of your codeignitor folder
4- Change uri_protocol from AUTO to PATH_INFO in Config.php file
Note: First of all you have to enable mod_rewrite from httpd.conf of apachi by removing the comments
In CodeIgniter 3.16 in using htaccess to
remove index.php file
& also
redirect HTTP to HTTPS
Follow are the codes:
application\config\config.php
file Make changes
$config['index_page'] = 'index.php';
To
$config['index_page'] = '';
RewriteEngine on
RewriteBase /
## Redirect SSL
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
## Remove fron url index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^/(index\.php|assets/|humans\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
try this one.It may help you as its working for me.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
put the code in your root htaccess file.and make sure that you have
$config['index_page'] = '';
in your config file.
Please let me know if you face any problem.
I think your all setting is good but you doing to misplace your htaccess file go and add your htaccess to your project file
project_folder->htaccess
and add this code to your htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
make .htaccess
file and put this code
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
change
$config['index_page'] = '';
remove index.php
present in config.php
file