I'm working with a codeigniter project and I am able to use codeigniter out of the box when I install it on a digital ocean ubuntu droplet. However, when I load this project I want to use, if index.php is not in the url, the project breaks and I see a 404 error: The requested URL was not found on this server.
There is a login page at domain.com/index.php/login Even when I login, it gets redirected to domain.com/dashboard without the index.php
This is my .htaccess:
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
This is my config.php:
$config['index_page'] = '';
$config['base_url'] = 'http://my_really_cool_domain.com';
Oddly enough, if I add /index.php/ to the base_url it works, but the CSS / javascript resources do not load. Not sure why I am facing this error.
You should apply changes as below :
Try to replace uri_protocol
in config.php
as it,
//find this `index_page`
$config['index_page'] = "index.php"
// replace with it
$config['index_page'] = ""
//find this `uri_protocol`
$config['uri_protocol'] ="AUTO"
// replace with it
$config['uri_protocol'] = "REQUEST_URI"
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
On my site, I use /etc/apache2/sites-enabled/000-default.conf
On your site it might be /default.conf
You need to add this line:
AllowOverride all
This is what my conf file looks like:
VirtualHost *:80>
<Directory /var/www/html>
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
Options +ExecCGI
DirectoryIndex index.php
AllowOverride all
</Directory>
DocumentRoot /var/www/html
Then restart apache: sudo service apache2 restart