Expand my Community achievements bar.

Redirects on AEMaaCS at Fastly (CDN)

Avatar

Level 1

I came across a use case to redirect the traffic from AEM Fastly based on uri, with the very limited access to Fastly, it seems not possible and setting up a new CDN for only redirect use case doesn't seem logical.

 

Need your inputs if anyone come across this use case? I want to avoid the redirects at dispatcher level to reduce latency due to the performance is key for the sites.

4 Replies

Avatar

Community Advisor

Hi,

you can contact Adobe, if you are using Adobe's CDN.



Arun Patidar

Avatar

Level 1

Does Adobe have additional privileges to add redirects rules at Fastly level as these seems not exposed to us.

Avatar

Employee Advisor

Have you already tried to send a 302 with a TTL, so it can be cached?

Avatar

Administrator

@vicky5677 Try using VCL snippets: VCL snippets are small pieces of code that can be inserted into Fastly's configuration to add custom functionality. This is a more efficient way to handle redirects than doing it at the dispatcher level because VCL snippets are executed at the edge of the network, which means that they can be cached.

Link: https://experienceleague.adobe.com/docs/commerce-cloud-service/user-guide/cdn/custom-vcl-snippets/fa... 

 

To redirect traffic from AEM Fastly based on URI using VCL snippets, you will need to create a dataset of redirects as a VCL table. This table should contain the following columns:

  • Source URI: The URI that you want to redirect from.
  • Destination URI: The URI that you want to redirect to.
  • Status code: The HTTP status code that you want to return with the redirect.

Here is an example of a VCL snippet that can be used to redirect traffic from /old-uri to /new-uri:

bereq.uri ~ "^/old-uri$" {
  rewrite "/new-uri" 301;
}

This snippet will match any request that starts with /old-uri and rewrite it to /new-uri. The 301 status code indicates that the redirect is permanent.



Kautuk Sahni