404 page not found codeigniter code example

Example 1: 404 page not found codeigniter

#Ubuntu 18.04
1.Add this in 000-default.conf or sitename.conf inside /etc/apache2/sites-enabled/

    <Directory /var/www/html>
        	Options Indexes FollowSymLinks
	        AllowOverride All
        	Require all granted
	</Directory>
    
2. And restart (sudo service apache2 restart)

Example 2: 404 page not found localhost codeigniter

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
Or

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]