Page Not found Error 404 auto redirected schema Script code

Page Not found Error 404 auto redirected schema Script code


Here's an example of a JSON schema for an auto-redirect configuration to handle a "Page Not Found" (Error 404) situation:

<script type='application/ld+json'>
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Auto Redirect - Error 404",
  "description": "Schema for configuring auto-redirect for Error 404 (Page Not Found)",
  "type": "object",
  "properties": {
    "sourceUrl": {
      "type": "string",
      "format": "uri",
      "description": "The URL of the page that generates the Error 404"
    },
    "redirectUrl": {
      "type": "string",
      "format": "uri",
      "description": "The URL to redirect the user to"
    },
    "redirectCode": {
      "type": "integer",
      "description": "The HTTP status code to use for the redirect (e.g., 301, 302)"
    }
  },
  "required": ["sourceUrl", "redirectUrl", "redirectCode"]
}
</script>

This schema represents a JSON structure for configuring an auto-redirect for the Error 404 (Page Not Found) scenario. It includes properties such as "sourceUrl" (the URL of the page that generates the Error 404), "redirectUrl" (the URL to redirect the user to), and "redirectCode" (the HTTP status code to use for the redirect, such as 301 or 302).

You can use this schema to validate JSON data that adheres to this structure when configuring auto-redirects for handling Error 404 situations. Feel free to customize or extend the schema based on your specific requirements.

Page Not Found fix schema code:

<script type='application/ld+json'>
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Page Not Found Fix",
  "description": "Schema for configuring a fix for Page Not Found (Error 404)",
  "type": "object",
  "properties": {
    "sourceUrl": {
      "type": "string",
      "format": "uri",
      "description": "The URL of the page that generates the Error 404"
    },
    "fixAction": {
      "type": "string",
      "description": "The action to take to fix the Page Not Found error"
    },
    "fixDetails": {
      "type": "string",
      "description": "Additional details or instructions for the fix"
    }
  },
  "required": ["sourceUrl", "fixAction"]
}
</script>


Or, Use Java script to fix this error:

 <script type='text/javascript'>
  fetch(`https://api.kitten.club/cats/${id}`)
 .then(res =&gt; res.json())
 .then((cat) =&gt; {
   if (!cat.exists) {
     // redirect to page that gives a 404
     window.location.href = &#39;/not-found&#39;;
   }
 });
 </script>

Comments

Popular posts from this blog

Office Tool_SPSS v23 + Serial key

How to Fix FATAL error Failed to parse input Document ?

How to Reduce Lazy Load Resources

Popular posts from this blog

Office Tool_SPSS v23 + Serial key

How to Fix FATAL error Failed to parse input Document ?

How to Reduce Lazy Load Resources