Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

283
Visualizações
Redirect automatically all links from one basic-URL to another?

I have the following problem: We have a website that has multiple hrefs for images - They all use the same domain. Which is something like:

<a href="http://img.example-domain.com">Avatar</a><br/>

But the server this domain is using is currently inactive, but it'll come back at some point, I just do not know when.

Now, we have a new image server, that is hosted on AWS. But since the code has many entries using the old domain, I would like to know how can I redirect ALL requests to that domain to another one, instead of editing the code itself.

For example Each request from "img.example-domain.com", shall be redirected to "img.example-domain.com.amazon.etc"

Please, how can I do this?

I am using Apache and would prefer a solution that involves using Apache Rewrite module or something like that... But if it is not possible, I will be OK too with a code solution.

Thanks in advance, to everyone.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You may add this to your .htaccess -->

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^img.example-domain.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.img.example-domain.com$
  RewriteRule (.*)$ http://www.img.example-domain.com.amazon.etc/$1 [R=302,L]
</IfModule>

Please note: the [R=302,L] only applies to "temporary" redirects, for a permanent solution, replace with [R=301,L]

about 4 years ago · Juan Pablo Isaza Relatório

0

you need to setup a new server to your domain that's redirects paths to the new one

you can do it with a simple node js server like this

const http = require("http");
const port = process.env.PORT || 8080;

const server = http.createServer((req, res) => {
  const path = req.url;
  res.writeHead(302, { "Location": "http://new-domain.com" + path });
  res.end();
});

server.listen(port);

Note: don't forget to change http://new-domain.com to the real new domain

Edited

You can even do it simply by using a free web host like heroku with this node js server and linking the host with the old domain

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda