Question

How to make redirect to 404 or root page when user types query to not existing page and SSI include gets error?

Or how to check if HTML-document exist on server and if doesn't then also make redirect?

If user types domain.tld?anyquerystringon my site then it includes anyquerystring.html HTML-page by SSI.

If user types query of not existing page like domain.tld?blahblahblah then it gives the [an error occurred while processing this directive] in the place of SSI include.

Was it helpful?

Solution 2

You can configure error message in SSI. The answer is

<!--#config errmsg="Put here your error message, HTML or other code" -->

OTHER TIPS

There is no way to check it with php, because if a page does not exists how your php code can run, you need to make changes to .htaccess file as it will tell the server to a redirect a user to a defined page in case of 404

RewriteEngine on
ErrorDocument 404 http://www.yoursite.com/404.php
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top