1

How do I remove the "index.php" from my URL?

Description

Using CI to build a simple MySQL-Php app, I cannot get rid of the "index.php" tag inside the URL:

localhost/CodeIgniter/index.php/Defult_Controller/index

.htaccess

application/.htaccess and application/cache/.htaccess:

<IfModule mod_rewrite.c>

# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
#  slashes.
# If your page resides at
#  http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/

RewriteEngine On
RewriteBase /CodeIgniter/
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]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>

apache.conf

LoadModule rewrite_module modules/mod_rewrite.so

application/config/config.php

$config['base_url'] = "http://localhost/CodeIgniter/";
$config['index_page'] = '';

PS: Im using codeIgniter 2.5.1 and xampp 3.2.1

Wolfpack'08
  • 3,412
  • 8
  • 41
  • 72
  • What happens when you go to `localhost/CodeIgniter/Defult_Controller/`? 404? – Mark Miller May 31 '14 at 04:30
  • @kasun Recommend screenshot in **Description**. – Wolfpack'08 May 31 '14 at 04:30
  • Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.7 (Win32) OpenSSL/0.9.8y PHP/5.4.22 – Kasun Gunathilaka May 31 '14 at 04:40
  • Please Check this Link http://stackoverflow.com/questions/14297770/cannot-remove-index-php-from-codeigniter-url – user3111011 May 31 '14 at 04:42
  • If I am not wrong, you need to place your `.htaccess` in your root folder to remove `index.php`, `application/.htaccess` is to avoid directory view. – Saravanan May 31 '14 at 04:45
  • Thanks, The problem Solved My .htaccess file was in side application directory I change it to root and now its working Thank you all – Kasun Gunathilaka May 31 '14 at 04:52
  • I have posted it as an answer, can you accept it as correct answer – Saravanan May 31 '14 at 05:37

1 Answers1

0

You need to place your .htaccess in your root folder to remove index.php, application/.htaccess is to avoid directory view.

Saravanan
  • 1,799
  • 2
  • 24
  • 28