1

First of all pardon me for asking this question as it has been discussed in number of times. I tried everything I came across but I feel I am doing something wrong. So I would appreciate some help in this case.

I want remove 'index.php' from urls. Currently the url is

http://localhost/eshop/index.php/home

But I want it like

http://localhost/eshop/home

This is my folder structure

Here is my .htaccess

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

I have also tried this

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

With this only "http://localhost/eshop/" is working but "http://localhost/eshop/home" or "http://localhost/eshop/contacts" are still failing.

Kuntal Basu
  • 830
  • 2
  • 12
  • 28
  • possible duplicate of [Remove index.php From URL - Codeigniter 2](http://stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2) – Sanoob Oct 26 '14 at 08:33

3 Answers3

1

In addition you should say to your CI didn't insert index.php to generated urls

https://ellislab.com/codeigniter/user-guide/general/urls.html

You also need to change config

$config['enable_query_strings'] = FALSE; 

There are several variant ( for exampl set index page as empty string - see this topic CodeIgniter removing index.php from url )

Community
  • 1
  • 1
Vasiliy vvscode Vanchuk
  • 7,007
  • 2
  • 21
  • 44
1

make a .htaccess file in root folder of project and paste this code

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

and in config.php

$config['base_url'] = '';
A.B
  • 20,110
  • 3
  • 37
  • 71
0

The following .htaccess should work.

RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Ariful Islam
  • 7,639
  • 7
  • 36
  • 54