V15HM4Y
V15HM4Y

Reputation: 1795

CodeIgniter: Placement of .htaccess file

I'm trying to configure CodeIgniter and remove index.php from the URL . I placed my .htaccess file with the applications folder and tried various codes posted by users. But it didn't work and index.php is still there. Initially the file was with the config folder. Can Anyone help me with this?

All suggestions are welcomed.... Thanks in advance...

Upvotes: 0

Views: 1414

Answers (4)

Shaiful Islam
Shaiful Islam

Reputation: 7134

You should place your .htaccess file at your root directory not Inside the application folder.

Keep following lines inside your .htaccess file and keep it at your root directory.It should work with and without index.php

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

Upvotes: 1

malar
malar

Reputation: 126

try this:

  RewriteEngine On
  RewriteBase /projects/hc/homecare/trunk/homecare 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
  RewriteRule ^(.*)$ /projects/hc/homecare/trunk/homecare/index.php?/$1 [L]

Upvotes: 0

AdrienXL
AdrienXL

Reputation: 3008

The only .htaccess you should edit is the one placed in your root directory of your website (or wherever your index.php file is).

your .htaccess should contain :

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

Also in your config.php set $config['index_page'] to empty :

$config['index_page'] = '';

Take a look at the the documentation : https://ellislab.com/codeigniter/user-guide/general/urls.html

Upvotes: 0

Stefan Cvetkovic
Stefan Cvetkovic

Reputation: 144

Go to application/config/config.php and edit next:

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

to:

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

If this doesn't work please post your .htaccess file content.

Upvotes: 0

Related Questions