my question is how to redirect any non existent link on my website back to the home page. For example; imagine i have a page called \"pets\" on my site (http://mywebsite.com/pet
Set ErrorDocument 404 /index.html
in your .htaccess file
Using mod_rewrite you can handle 404 (page not found) like this:
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule . / [L]
This will preserve original link in the browser but will show your home page.
you can use mod_rewrite
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [R]
Equip the 404-page with a javascript redirect. Make sure it is timed, so visitors can see what happened.