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.

1

3 Answers 3

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 )

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

2 Comments

I have this flag false. But it doesn't help.
try to set $config['index_page'] and $config['base_url'] as empty string
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'] = '';

1 Comment

I have already tried this, but it always gives me 500 Internal Server Error.
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]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.