I mentioned my htaccess rewrite rule below If I enter a wrong url, for example: 'http://example.com/hosting/web-hosti' directs to 'http://example.com/main-page.php?pagename=web-hosti' where 'web-hosti' page doesn't exist. or 'http://example.com/contac' directs to 'http://example.com/sub-page.php?pagename=contac' where 'contac' page doesn't exist. Can anyone please tell me how to redirect all wrong urls to 404 page?
RewriteEngine ON ##Rules for existing php files rewrite. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)/?$ $1.php [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^hosting/(.*)/?$ main-page.php?pagename=$1 [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/?$ sub-page.php?pagename=$1 [NC,L] ErrorDocument 404 /404.php RewriteCond %{REQUEST_URI} ^/404/$ RewriteRule ^(.*)$ /404.php [L]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)