I\'m using Ubuntu 13 with the following setup for a local codeigniter site.
Apache/2.4.6 (Ubuntu)
5.5.3-1ubuntu2.2
\'CI_VERSION\', \'2.1.2\'
It doesn’t seem like CodeIgniter has a default .htaccess
, so unclear where that came from. But for debugging purposes, I would recommend you do the following. First, here is your .htaccess
all cleaned up:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Now replace your index.php
with this. It just dumps the $_GET
values passed via the .htaccess
like so:
echo '<pre>';
print_r($_GET);
echo '</pre>';
Now with that in your .htaccess
load the index page of the site/app/project in question. The output should be something like this:
Array
(
[/controllername/here/] =>
)
Which appears to be correct. But again, you would know better than us.
The purpose of doing this is to assess whether the issue is either in Apache passing proper $_GET
values to your CodeIgniter setup, which is one issue. Or whether the issue is within your CodeIgniter controller logic itself.
My gut tells me the issue is in the CodeIgniter logic in your codebase since the upgrade from Ubuntu 12.x
to Ubuntu 13.x
includes an upgraded version of PHP
from version 5.3
in Ubuntu 12.x
to version 5.5
in Ubuntu 13.x
. I am using lots of code that works in PHP 5.3
and PHP 5.4
but breaks at times in PHP 5.5
since there are major changes in that codebase that will cause code to break if you don’t keep on top of non-depreciated functions & such.
Place the .htaccess file in the project folder like this:
htdocs/your_project/.htaccess
Try this new code for .htaccess:
RewriteEngine on
RewriteBase /your-project-directory-name/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I would try something like:
RewriteRule ^(?!index)(.*)$ index.php?/myvariable=$1 [L]
If you know what GET variable the script is expecting for controllername
in localhost/controllername
, then in the rule replace myvariable
with that variable name.
copy following code to .htaccess
in your root folder
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Options All -Indexes
This works fine for me to remove index.php in CodeIgniter.