3
votes

I'm using Codeigniter framework, i test the website on shared hosting and it work fine with .htaccess. but when i upload it to an other server who has Nginx, i can't remove index.php. I tried almost all googel's two first pages i had the same result none of them worked for me, i want to remove index.php from URL. this is the htaccess that worked for me.

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

i want the corespond of this htaccess in nginx.config. i don't know what's the problem.

3
You googled it, so what happens when you use first result? - Tpojka
@Tpojka nothing. all links without index.php. but they don't work until i add index.php manuly. - ler
Have you tried to restart nginx after changes? - Tpojka

3 Answers

0
votes

This was driving me nuts too.

Turned out playing with this in the config.php file helped.

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

I'm using the same htaccess rules at present too

0
votes

Try This For Better Solution

Step 1: Remove index.php from config.php. Open 
/application/config/config.php 
and remove index.php to “” ...
Step 2: Edit htaccess file – For Apache Server. NOTE: This step is not for 
nginx server users, Please check Step 2 for Nginx. ...
Step 3: Edit nginx.conf file – For NGINX Server.
0
votes

Step 1 : go to codeigniter folder, open the file config.php and remove "index.php" from $config['index_page'] = ''

Step 2 : Create .htaccess file in codeigniter folder and paste below code

RewriteEngine On
RewriteBase /codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

or

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Step 3 : find

      $config['uri_protocol'] = "AUTO" 

and replace with

      $config['uri_protocol'] = "REQUEST_URI"

also check

      $config['enable_query_strings'] = FALSE;

Step 4 :restart xampp server and check ..