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

219
Visualizações
Is it possible for the RewriteEngine (.htaccess) not to seemingly remove the headers?

I have a small ajax running with php on a server. That directory has a .htaccess which has the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^exampleDomain\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.exampleDomain.com/$1 [R,L]

This part is meant to redirect the http requests to https. However, I call the ajax from outside the domain, so I added:

Header set Access-Control-Allow-Origin "*"

This is meant to tell the browser to ignore CORS policy.

I am using jQuery to make a get request (I don't think jQuery is the problem), and it only works with https. If I make a request to http://exampleDomain.com, the server will not respond with the access-control-allow-origin header. On the contrary, http://www.exampleDomain.com, https://www.exampleDomain.com and https://exampleDomain.com all respond with the header. I want to keep the HTTP upgrade functionality, whether that is using .htaccess or not, without it interfering with the headers sent back.

This is the code that makes the failed request:

$.get("http://exampleDomain.com/path/to/file.php", {}, res => console.log(res))

Ideally, I would just change the request to https, but the code is already in production.

I am using Apache2 and PHP7.

over 4 years ago · Santiago Trujillo
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