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?

2
  • Have you get mod_rewrite running on the server ? phpinfo() will tell you if its enabled Commented Nov 11, 2013 at 2:29
  • you can check the following url... stackoverflow.com/questions/14297770/… Commented Feb 6, 2014 at 6:14

5 Answers 5

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';

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

Comments

0

Open application/config/config.php, and change

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

to

$config['index_page'] = '';

2 Comments

Sorry, forgot to mention I already made that too, without success.
Try removing the leading slash: RewriteRule ^(.*)$ index.php/$1 [L]
0

Try this one :

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

Comments

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.

1 Comment

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?
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.

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.