Ir para o conteúdo

Route domain to specific directory in Cloudfront

0

We have a software sold in installs and each install has a ton of images. The plan was to move those images to a single CloudFront distribution and each install's images would simple occupy its own directory. Definitely would work but we would loose SEO credit.

Question, is there a way to use a "alternate domain" that points to a sub-directory rather that the distribution itself? That would be too easy, probably need to sacrifice the SEO for a single distribution or create a distribution per install?

feita há 3 anos406 visualizações
1 Resposta
1

Might need more information to gauge the SEO impact.

With regards to the question, it would be easier to create a distribution per install as we could simply rely on Origin Path parameter [1] to append the directory name into URI. For instance, example.com/a.img would be example.com/path/a.img sending back to the origin.

On the other hand, we could also use CloudFront Functions or Lambda@Edge to dynamically adjust the request URI based on the needs. For example, the following CloudFront Functions would modify the URI according to the host name (alternate name):

function handler(event) {
    var request = event.request;
    var headers = request.headers;
    var host = request.headers.host.value;
    var uri = request.uri;

    if (host === 'example.com') {
        // If the host is example.com, prepend /example to the URI
        request.uri = '/example' + uri;
    } 
    
    return request;
}

Lastly, I would also recommend reading this article [2] for SEO optimization with Amazon CloudFront.


[1] https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath

[2] https://aws.amazon.com/blogs/networking-and-content-delivery/optimize-seo-with-amazon-cloudfront/

AWS
respondido há 3 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.