0

I'm having some trouble removing index.php from my CI app urls. Followed the official documentation here but apparently something's missing yet. I setup a CI app and placed it on /var/www/test on my server, where test is a symlink pointing to /home/user/websites/test. Everything is working fine if I do http://myIp/test/index.php/welcome, but working if I do http://myIp/test/welcome. I included an .htaccess in my test folder, containing the following:

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

and also played with RewriteBase property without success. What am I doing wrong or missing?

Rui
  • 5,900
  • 10
  • 38
  • 56
  • Have you get mod_rewrite running on the server ? `phpinfo()` will tell you if its enabled – bart_88 Nov 11 '13 at 02:29
  • you can check the following url... http://stackoverflow.com/questions/14297770/cannot-remove-index-php-from-codeigniter-url/14301819#14301819 – Hasib Tarafder Feb 06 '14 at 06:14

5 Answers5

1

put the following in .htaccess

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

<Files "index.php">
AcceptPathInfo On
</Files>

put this file near to index.php out of application and system folders and near to them don't forget to write $config['index_page'] = ''; instead of $config['index_page'] = 'index.php';

Sally
  • 31
  • 7
0

Open application/config/config.php, and change

$config['index_page'] = 'index.php'; 

to

$config['index_page'] = '';
GluePear
  • 7,244
  • 20
  • 67
  • 120
0

Try this one :

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php?/$1 [L]
tcj
  • 1,645
  • 4
  • 13
  • 21
0

Your rewrite rule is incorrect (or faulty at best). It should be as follows

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

The [L] flag in the RewriteRule indicates to apache that no further rules should be processed and that the rule should be applied immediately. See the apache documentation about the L flag for more information on this. In your case this is important due to the fact that you are using symlinks and .htaccess file instead of applying the rule to your vhost file directly, which is highly recommended given this case as well as the case that .htaccess is slow.

Sherif
  • 11,786
  • 3
  • 32
  • 57
  • It doesn't work also... Am I doing something wrong? I placed my CI test app on the default Apache web folder (/var/www) through a symlink, without further configurations. I'm editing the .htaccess in the root of the test app. Something wrong here? Can this be something related to permissions somehow? – Rui Nov 10 '13 at 23:49
0

If i have got your question right you want to make your links working & remove 'index.php' from URL.Follow following steps & let me know if that solves your issue.

1) Remove 'index.php' from config.php which is located in config directory make it look like this $config['index_page'] = '';

2) Add this to .htaccess file

DirectoryIndex index.php
RewriteEngine on

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

If you have any doubts or issues let me know.Hope it helps.

Best Regards, Zeeshan.

Zeeshan
  • 803
  • 6
  • 15