Remove index.php from url in CodeIgniter 3
Update your htaccess file with the below code
RewriteEngine On
RewriteBase /demo
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
and in config file, please change base url with below code:-
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
How to remove index.php in codeigniter's path
If you are using Apache place a .htaccess file in your root web directory containing the following:
RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Another good version is located here:
http://snipplr.com/view/5966/codeigniter-htaccess/
Removing index.php from CodeIgniter URL
This setting worked for me.
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
To allow overriding htaccess in Apache Configuration you have to edit and change /apache2.conf
file to
AllowOverride All
And restart server.
CodeIgniter removing index.php from URL not working
You don't have to edit index.php, replace the content .htaccess file to:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Codeigniter 3.1.6 - How to remove index.php from url
Change folder name CodeIgniter-3.1.6
to ci
Set your base_url
to
$config['base_url'] = 'http://localhost/ci/
Use this .htaccess
RewriteEngine On
RewriteBase /ci
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
While removing index.php from url in codeigniter, i am getting following error .Not Found The requested URL was not found on this server
Codeigniter 4 have two different .htaccess files, you need to change the one in public folder:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Related Topics
Remove Trailing Slash from String PHP
Oauth Implementation in Netsuite Using PHP
File Attachment with PHPmailer
How to Add Paths to the Apache Path Variable
Call Another PHP Script and Return Control to User Before the Other Script Completes
How the Usort() Sorting Algorithm Works
Algorithm to Get the Excel-Like Column Name of a Number
Strict Standards: Only Variables Should Be Assigned by Reference PHP 5.4
Yii2 Translation Does Not Work
How to Execute PHP with Extension File.Php.Jpg
Fix Incorrectly Displayed Encoding on an HTML Document with PHP
Getting a PHP Pdo Connection from a MySQL_Connect()
PHP Warning: Exec() Unable to Fork
Datetime Class VS. Native PHP Date-Functions
How to Bind an Arbitrary Number of Values to a Prepared Statement in MySQLi