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;
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]
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/
CodeIgniter: removing 'index.php' from URL
Use this in your .htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
place ./ before your index.php rewrite rule.
or this
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
For more detail refer link:https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html
Remove index.php from url in codeigniter using htaccess
Hope this will help you :
Options +FollowSymlinks -Indexes
RewriteEngine on
DirectoryIndex index.php
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
and also set your config.php:
$config['index_page'] = '';
$config['base_url'] = 'http://localhost/foldername/';
for more : https://www.codeigniter.com/user_guide/general/urls.html
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.
Removing index.php in url using .htaccess but failed
I'm not sure what operating system your are working on, but make sure mod_rewrite
is enabled if you are on linux
then follow these steps, here is the simplest .htaccess
rules:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Save this file in your FCPATH
, then go to your config.php
under application/config
and make sure to set the base_url
in:
$config['base_url'] = 'http://localhost/myhems/';
and delete the value in index.php
in:
$config['index_page'] = '';
CodeIgniter Remove index.php in URL
change in .htaccess file and try it
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Related Topics
Is "MySQLi_Real_Escape_String" Enough to Avoid SQL Injection or Other SQL Attacks
How to Generate Xml File Dynamically Using PHP
How to Convert an Array to Object in PHP
How to Get Parameters from a Url String
How to Run PHP from Windows Command Line in Wampserver
What in Layman'S Terms Is a Recursive Function Using PHP
Difference Between Http_Host and Server_Name in PHP
PHP Exec() VS System() VS Passthru()
Convert Time in Hh:Mm:Ss Format to Seconds Only
Using Braces With Dynamic Variable Names in PHP
How to Call a JavaScript Function from PHP
How to Convert Json String to Array
Best Way to Insert Many Values in MySQLi