search widget

Simple HtAccess Rewrite Code for Hosting CodeIgniter on Shared Hosting and avoid 404 error

Sunday, May 27, 2018

Incase you are experiencing 404 error after uploading your codeigniter files on your shared host like Namecheap, GoDaddy, GreenGeeks e.t.c, add the code below in your Htaccess file and you should be good to go.

<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php

If above code doesn't work for you, you can see source here:

No comments:

Post a Comment