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'
And URLs are no longer working without index.php
. They used to work, but after upgrading from Ubuntu 12.x
to 13.x
and a few apache updates over the past year, the localhost
sites no longer work right.
if I go to localhost/index.php/controllername/
it works but if I go to localhost/controllername/ it does not.
mod_rewrite
is enabled.
CodeIgniter config has:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; // tried all available options here and
Nothing worked
in the .conf
file for the domain I have this:
<Directory />
Options -Multiviews +FollowSymLinks
AllowOverride All
</Directory>
and here's the .htaccess
file commented lines are ones I tried that didn't work.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
# RewriteRule .* index.php/$0 [PT,L]
# RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I’ve Googled and read everything I can find and tried everything I could find including several posts here on Stack Overflow, including the ones in the “Questions that may already have your answer.” Still nothing seemed to work. But like I said, this worked in the past, but only after multiple updates to the OS and Apache did I first notice it stop working.
I’ll be moving away from CodeIgniter with future projects, but these projects already existed. Baffled as to what could be the issue.
SOLUTION:
turns out it was not a codeigniter issue at all. It was an apache issue but not with the rewrite rules. in my apache2.conf I had to alter the block for /var/www/
Require all granted seems to have done the trick.
DirectoryIndex index.php index.html Options Indexes FollowSymLinks AllowOverride All Require all granted
just for good measure, I made the change here as well: Options FollowSymLinks AllowOverride All Require all granted
found on askubuntu https://askubuntu.com/questions/421233/enabling-htaccess-file-to-rewrite-path-not-working
mod_rewrite
is enabled? It’s not be default:sudo a2enmod rewrite
. And thensudo service apache2 restart
. – Giacomo1968