0

I have tried a lot to remove index.php from the url . Its not working at all.

In config.php

$config['index_page'] = '';

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

Then put this below code in .htaccess of my project root.

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

I have tried ,its throwing page not found errors only. enter image description here

enter image description here

enter image description here Any suggestion ?? Thank you

sradha
  • 2,196
  • 1
  • 25
  • 47

4 Answers4

1

You need to change config.php and .htaccess file.

Changes in application/config/config.php

$config['index_page'] = ""; // And Remove index.php

Changes in .htaccess

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Make Sure

  1. Your .htaccess must under cloud directory.

  2. Rewrite module must be enabled in Apache.

Hassaan
  • 6,770
  • 5
  • 29
  • 47
  • http://localhost/cloud/index.php/dashboard/index Its in local host ..i canot show you . I want to remove index.php The link should be . http://localhost/cloud/dashboard/index – sradha Dec 22 '16 at 11:02
  • 1
    @sradha please check in `application/config/routes.php` default_controller should be `$route['default_controller'] = 'dashboard';` – Hassaan Dec 22 '16 at 11:05
  • But my default controller is login ,first login page will come so i gave login – sradha Dec 22 '16 at 11:16
  • @sradha is login is working without `index.php` in url? – Hassaan Dec 22 '16 at 11:20
  • Yes if i am giving http://localhost/cloud/ Login page is coming . As i have mentioned $route['default_controller'] = 'Login'; – sradha Dec 22 '16 at 11:21
  • after logout this one is coming . http://localhost/cloud/index.php/login – sradha Dec 22 '16 at 11:23
  • @sradha http://localhost/cloud/login is working, It means you rewrite is working .... – Hassaan Dec 22 '16 at 11:24
  • @sradha what is `base_url` in `config.php`? – Hassaan Dec 22 '16 at 11:26
  • @sradhaI have update my answer. Please make sure points in my answer – Hassaan Dec 22 '16 at 11:28
  • Your .htaccess must under cloud directory. Rewrite module must be enabled in Apache. This two is fine here... – sradha Dec 22 '16 at 13:57
1

Your base URL is not the base domain name, so modify your .htaccess file and add the following:

RewriteBase /cloud

This should fix your issues.

James Lalor
  • 1,216
  • 9
  • 21
0

try this ,
Changes in .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Dave
  • 3,046
  • 7
  • 19
  • 32
0

Make sure your RewriteEngine is on in apache conf file if not then follow this link

How to enable mod_rewrite for Apache 2.2

Community
  • 1
  • 1
Niklesh_Chauhan
  • 647
  • 5
  • 16