Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

208
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda