---
title: Redirect 403 Forbidden to a different page
description: If origin responded with `403 Forbidden` error code, redirect to different page.
image: https://developers.cloudflare.com/core-services-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/rules/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Redirect 403 Forbidden to a different page

If origin responded with `403 Forbidden` error code, redirect to different page.

JavaScript

```
export default {  async fetch(request) {    // Send original request to the origin    const response = await fetch(request);    // Check if origin responded with 403 status code    if (response.status == 403) {      // If so, redirect to this URL      const destinationURL = "https://example.com";      // With this status code      const statusCode = 301;      // Serve redirect      return Response.redirect(destinationURL, statusCode);    }    // Otherwise, serve origin's response    else {      return response;    }  },};
```

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/rules/snippets/examples/redirect-forbidden-status/#page","headline":"Redirect 403 Forbidden to a different page · Cloudflare Rules docs","description":"If origin responded with 403 Forbidden error code, redirect to different page.","url":"https://developers.cloudflare.com/rules/snippets/examples/redirect-forbidden-status/","inLanguage":"en","image":"https://developers.cloudflare.com/core-services-preview.png","dateModified":"2025-10-13","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["Redirects"]}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/rules/","name":"Rules"}},{"@type":"ListItem","position":3,"item":{"@id":"/rules/snippets/","name":"Cloudflare Snippets"}},{"@type":"ListItem","position":4,"item":{"@id":"/rules/snippets/examples/","name":"Snippets examples"}},{"@type":"ListItem","position":5,"item":{"@id":"/rules/snippets/examples/redirect-forbidden-status/","name":"Redirect 403 Forbidden to a different page"}}]}
```
