Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!