Remove Index.PHP from Url - Codeigniter 2

Remove index.php in codeigniter 2.1.0

In application/config.php make sure that

$config['index_page'] = "";

Then set this as your .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>

You're all set!

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 using codeigniter 2

In .htaccess add following line after RewriteEngine on

RewriteBase    /training/belajaradmin/

Edit config as follows:

$config['base_url'] = ''; 
$config['index_page'] = '';

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/

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

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]

Codeigniter URL rewrite to remove index.php

OK, You mentioned lot of Stack links which related to your question.

Change this settings

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

and add this in .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Note: Some time in localhost index.php will not removed.

and to include your css/js/images

CSS:<link rel="stylesheet" href="<?php echo base_url()?>assets/styles/material-design-icons.css" type="text/css" />

JS : <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/in/easing.js"></script>

Img: <img src="<?php echo base_url()?>assets/image/logo.jpg" alt="Sample Image"/>

So file structure would be

- application
- assets
- style
- material-design-icons.css
- font.css
- app.css
- js
- easing.js
- image
- logo.jpg
- index.php
- .htaccess(Post in my code)

EDIT 01

In config/routes.php

$route['default_controller'] = "";//give default controller name
$route['404_override'] = '';

Removing index.php from CodeIgniter url redirects to localhost

RewriteEngine on
RewriteBase /job
RewriteCond $1 !^(index\.php|images|table-images|robots\.txt|styles|js|uploads)
RewriteRule ^(.*)$ index.php/$1 [L]

and set in application/config/config.php

$config['base_url'] = 'http://127.0.0.1:8000/job/';
$config['index_page'] = 'index.php';


Related Topics



Leave a reply



Submit