> For the complete documentation index, see [llms.txt](https://docs.transparentedge.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.transparentedge.eu/getting-started/faq/features/http-redirects.md).

# HTTP Redirects

#### Redirect to HTTPS

When your website runs with SSL, it’s typical to want everything that comes in unencrypted via HTTP to be sent to the secure version to make sure nobody is browsing your website insecurely. To do so, you just have to call `redirect_https`.

```perl
 sub vcl_recv {  
     if (req.http.host == "www.transparentcdn.com") {
         call redirect_https;
     }
}
```

#### Redirects 301 and 302

Redirects can be performed by calling the function \``redirect_request`\`, see [callable functions](/config/vcl/callable-functions.md).

```perl
sub vcl_recv {
    # 301
    if (req.http.host == "example.com" && req.url ~ "^/old-section") {
        # req.http.tcdn-location header is required for this call to work.
        set req.http.tcdn-location = "301, https://www.example.com/new-section/";
        call redirect_request;
    }

    # 302
    if (req.http.host == "example.com" && req.url == "/") {
        set req.http.tcdn-location = "302, https://www.example.com/es/";
        call redirect_request;
    }
}
```

It’s important to understand the implications of the two types of redirects. A 301 is a redirect that, in theory, isn’t going to change, so it gets cached in browsers. If it does eventually change, it’s very complicated to un-cache that resource.

A 302, meanwhile, is a temporary redirect for a resource, so it’s not cached in browsers or intermediate proxies.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.transparentedge.eu/getting-started/faq/features/http-redirects.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
