Codeigniter routes works in local server. when I deploy to var/www/html
of server, the routes not working as expected.
when I add index.php
before controller name in URL, it works fine.
but without index.php
, it throws 404 page not found error
.htaccess
file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I tried this as well
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /var/www/html/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
but nothing works..
3
Answers
Try below solution:
go to applicationconfigconfig.php file
Make changes
To
.htaccess
STEP 1
go to application/config/config.php
find
STEP 2
go to application/config/routes.php
remove everything from the bottom of the page after the comment ends and paste below code
STEP 3
add a new file named as .htaccess in the root folder where you have the folders named application and system etc
add the below code and open the website
It seems like mod_rewrite is not enabled in your server.
If the rewrite rule isn’t working, ensure you are allowing .htaccess files in your Apache config file. The directory section should contain an AllowOverride All option:
Don’t forget that any changes to the Apache config file require a service restart!