1

I am trying to remove 'index.php' from the URL. I have tried by making

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

as

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

and

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

as

$config['index_page'] = '';

and even tried with putting

RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /project/index.php/$1 [L]

in .htaccess file, but it not working me. Can anyone please tell me where I am going wrong? Thanks in advance..

1
  • What OS are you running? Windows? Ubuntu? OSX? Commented Feb 13, 2013 at 7:22

4 Answers 4

1

Given that you've told me you're using Ubuntu...

  1. Use the .htaccess configuration provided by Ayman.
  2. Open a terminal and type sudo a2enmod rewrite to enable mod_rewrite on your machine.
  3. Open 000-default with sudo nano /etc/apache2/sites-enabled/000-default and change the first occurence of AllowOverride None to AllowOverride All

Then restart apache with sudo service apache2 restart.

Also use: $config['index_page'] = '';

Sign up to request clarification or add additional context in comments.

2 Comments

I know its not in proper format, but sorry, I cant answer my own questions because I don't have 10 reputations
+1 Now you will. Welcome to SO and enjoy CI.
1

There are 3 steps to remove index.php

1.Make below changes in application/config.php file

$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

2.Make .htacces file in your root directory using below code

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

3.Enable rewrite mode

i. First, initiate it with the following command:

a2enmod rewrite

ii. Edit the file /etc/apache2/sites-enabled/000-default

change the AllowOverride None to AllowOverride All.

iii. Restart your server with the following command:

sudo /etc/init.d/apache2 restart

Comments

0

Got the answer, I just had inserted the following code in my .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

and made $config['index_page'] = '';

in config.php

source: Remove "index.php" from URL - Codeigniter‌​r

Answered by: @Akhilraj N S

Comments

0

This is the .htaccess file I always use. Works for me:

<IfModule mod_rewrite.c>
  DirectoryIndex index.php
  RewriteEngine on
  RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteBase /project/
  RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

7 Comments

And should I keep the .htaccess file in application folder or the main project folder along with the application folder?
Keep it in the main project folder
It is still taking index.php
The .htaccess file should go in the root of your project folder. Right next to application and system; not inside.
Change $config['uri_protocol'] back to AUTO.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.