vrajesh
vrajesh

Reputation: 2942

Codeigniter remove index.php from URL localhost:82/project

I have URL

http://localhost:82/project/index.php/home

I want to remove index.php from above url.

Like this : http://localhost:82/project/home

I have used many solution

1) I have remove index.php from config.php file :

$config['index_page'] = '';

2) change "uri_protocol" in config.php file :

$config['uri_protocol'] = 'REQUEST_URI';

My htaccess :

RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Anybody master here to solve my question ? Thanks in advance.

Upvotes: 0

Views: 840

Answers (4)

Pyae Phyo Aung
Pyae Phyo Aung

Reputation: 270

If you are using Apache Server, you must do mod_rewrite enabled. And then modify your .htaccess file with the code below.

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

For more information, visit here

Try similar question here

Upvotes: 1

gauri
gauri

Reputation: 131

Set your base URL in config as

$config['base_url'] = 'http://localhost:82/project/'

In your .htaccess, Try with this, I have used this in my CI projects.

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

Place this file in your project folder.

Folder structure

Upvotes: 1

Mhrishad
Mhrishad

Reputation: 246

Try To Use This

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

I use it and work on me. Thank You

Upvotes: 1

curiosity
curiosity

Reputation: 844

use this Codeigniter .htaccess file and install it to your root app.

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

Like this one...

project_name
    -application
    -assets
    -system
    -user_guide
    -.htaccess // like this one

Upvotes: 1

Related Questions