2

Using Apache2 installed on windows 7, I use the htaccess configuration below to remove the index.php from codeigniter url:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

Could someone please tell why the configuration above does not work on ubuntu. I have enable mod rewrite using sudo a2enmod rewrite. Thanks

vkrams
  • 7,267
  • 17
  • 79
  • 129
lomse
  • 4,045
  • 6
  • 47
  • 68
  • possible duplicate of [How to remove "index.php" in codeigniter's path](http://stackoverflow.com/questions/1445385/how-to-remove-index-php-in-codeigniters-path) – stormdrain Aug 21 '13 at 19:20
  • No error except I have to add index.php before controller before it can work. example: http://site.com/login will not work but http://site.com/index.php/login works. What is weird is that, with the same configuration, http://site.com/login works perfectly on apache2 installed on windows 7 – lomse Aug 21 '13 at 19:21
  • 1
    Did you change `AllowOverride None` to `AllowOverride All` in `/etc/apache2/sites-available/default`? https://drupal.org/node/134439 – stormdrain Aug 21 '13 at 19:26
  • yes I did change AllowOverride None to AllowOverride All, rebooted the server but still the same issue – lomse Aug 21 '13 at 19:28

1 Answers1

2

This is probably because the ubuntu server is setup to pass PATH_INFO, meaning you don't need the query string. You can probably just remove the ? from your rule and it should work:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
# no query string ----------^
Jon Lin
  • 142,182
  • 29
  • 220
  • 220