Search code examples
html.htaccesshttp-redirectssiserver-side-includes

How to make redirect if HTML-document doesn't exist on server


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.


Solution

  • You can configure error message in SSI. The answer is

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