How to Remove "Index.PHP" in Codeigniter'S Path

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 the index.php in routing in Codeigniter

Okay, assuming (as you stated) that your codeigniter setup is stored in the directory /vote/.

You should be able to do something like this in the htaccess file to be able to access it without the index.php

RewriteEngine on
RewriteBase /vote/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Here is some more reading related to Codeigniter URL's

CodeIgniter URI Routing - How to remove index.php

There is a simple solution to using URI routing in CodeIgniter.

If you open the routes.php file in the config folder you can map URI's to controllers and methods.

In your case, it would work something like this:

$route['KWeds_svn/kweds_hmvc'] = 'UserController/homeIndex';

Also you need to figure out how to remove the index.php from the URI, to do this, use the following steps:

Go to config.php and change

$config['index_page'] = 'index.php';

to

$config['index_page'] = '';

Then go into the document root folder (where the config, application folders are held) and create a new file called .htaccess, in this file write the following code:

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

If you are hosting your own server, you may need to enable the rewrite module in apache. To do this, go to the command line for your server and type the following:

sudo a2enmod rewrite

Hope this helps!

Remove index.php from codeigniter in subfolder

try this

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

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;

remove index.php codeigniter

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

write this in your htaccess

check this link to enable mod_rewrite function of
apache setting

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'] = '';

how to remove index.php from codeigniter path

HTACCESS

RewriteEngine on
RewriteRule ^(.*)$ ./index.php/$1 [L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)


Related Topics



Leave a reply



Submit