2

I've read guides on its removal and they tell me to add this to a .htaccess in my htdocs root directory:

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

However my websites directory is like so: htdocs\mywebsite\

I've tried adding the htaccess file in both htdocs and mywebsite but without result. I've also tried modifying the last line to look like

RewriteRule ^(.*)$ mywebsite/index.php/$1 [L]

In both htdocs and mywebsite directory. But I have no idea what is correct .htaccess syntax or how it works, so I didn't really expect it to work.

I've also tried modifying the .htaccess file everywhere else in the codeigniter dir tree.

styke
  • 2,116
  • 2
  • 23
  • 51

3 Answers3

3

Have you seen this one? How to remove "index.php" in codeigniter's path

Did you change the index_path variable in the config file? That's application/config/config.php, line 29 in version 2.1.3

Community
  • 1
  • 1
dmgig
  • 4,400
  • 5
  • 36
  • 47
  • I wasn't aware I had to change the index_path. What should I change it to? – styke Nov 26 '12 at 19:20
  • 1
    make it an empty string: $config['index_path'] = ''; That's it, I think – dmgig Nov 26 '12 at 19:22
  • I think you need to add your .htaccess file to wherever your index.php file is, did you do that? Look over the link I sent as well. – dmgig Nov 26 '12 at 19:27
  • Yep, it's both in the root and mywebsites directory. I used the improved code found in the link. Still not working. – styke Nov 26 '12 at 19:30
1

There needs to be a htaccess file in both the root and website directory. They need to both contain the same content except the file in root needs to have the path to the index updated to include your website dir.

Root dir:

RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ yourwebsite/index.php/$1 [QSA,L]

Web dir:

RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]
styke
  • 2,116
  • 2
  • 23
  • 51
0

Make sure you have this in your virtual host entry:

    <Directory "/path...to directory">
        Order allow,deny
        Allow from all
        Allowoverride all
    </Directory>

    <IfModule mod_rewrite.c>
        RewriteEngine on
    </IfModule>

You don't need to modify any .htaccess files except in the root. And as mentioned above, make sure you have things set up right in the config.php file.

Kenzo
  • 3,513
  • 4
  • 17
  • 16