Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:08:50+00:00 2026-06-14T16:08:50+00:00

I’ve added everything to my Apache htaccess: Header set Access-Control-Allow-Headers: X-Requested-With Header set Access-Control-Allow-Methods:

  • 0

I’ve added everything to my Apache htaccess:

Header set Access-Control-Allow-Headers: X-Requested-With
Header set Access-Control-Allow-Methods: OPTIONS
Header add Access-Control-Allow-Methods: GET
Header add Access-Control-Allow-Methods: POST
Header add Access-Control-Allow-Headers: Content-Type
Header add Access-Control-Allow-Headers: Depth
Header add Access-Control-Allow-Headers: User-Agent
Header add Access-Control-Allow-Headers: X-File-Size
Header add Access-Control-Allow-Headers: X-Requested-With
Header add Access-Control-Allow-Headers: If-Modified-Since
Header add Access-Control-Allow-Headers: X-File-Name
Header add Access-Control-Allow-Headers: Cache-Control
Header set Access-Control-Allow-Origin: http://mysite.com 
Header add Access-Control-Allow-Origin: https://mysite.com
Header set Access-Control-Allow-Credentials: true

I added this to my jquery $.ajax:

xhrFields: {
    withCredentials: true
}

Absolutely nothing works.

I’m doing $.ajax with

type: 'POST',
dataType: 'json'

I thought by setting all of those headers above, I could do json not jsonp (please no jsonp. anything but jsonp. i can’t get success to fire. please.god.no)

I’m at my limits. I’m getting the good ole

XMLHttpRequest cannot load https://mysite.com/aDirectory/aSecureFile.php. Origin http://mysite.com is not allowed by Access-Control-Allow-Origin.

Please help. I’m dying here. I promise I’ve looked everywhere, oh, have I looked everywhere.

Many thanks in advance!

Clarity

My headers are all coming across. I can see them in my response headers, but I’m still getting the above error. Is the server blocking? The browser? Is there something special I have to do to do https? Is there another setting on Apache I have to set to allow CORS? Is my jQuery $.ajax correct? Aside from data and success and error (and the URL always being https), that’s all I’m doing to the jQuery $.ajax.

Thanks again!

new

Cross Domain AJAX preflighting failing Origin check didn’t help (I don’t think). Added

Header set Access-Control-Allow-Headers: ORIGINS

(adjusting for sets and adds). All response headers coming down the pipe.

newer

Added these

Header add Access-Control-Allow-Headers: Origin
Header add Access-Control-Allow-Headers: Accept

still nothing

REQUEST HEADERS

Do these help?

Accept:application/json, text/javascript, /; q=0.01
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Origin:http://mysite.com
Referer:http://mysite.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11

PHP

header("Access-Control-Allow-Origin: http://mysite.com");
header("Access-Control-Allow-Origin: https://mysite.com");

RESPONSE HEADERS CLARITY

The RESPONSE HEADERS are coming through on all normal requests not the cross domain https ajax.

Server

CentOS 5.8, Apache 2.2.2, PHP 5.3, cPanel, WHM

Fine, if PHP not executing

So, in my haste, I copied slashingweapon’s cors.php directly without php tags. I made a test page with $.ajax using the settings above.

It worked (as in there were no errors when the ajax fired) complete with response headers. As soon as I added the tags to the PHP, the error happened. I checked to see if it was a directory issue, putting it in both root and a subdirectory, fine as long as PHP is not executing.

Does this mean anything to anyone?

Is there a PHP setting that needs to be flipped?

Thanks to all for grinding this out with me!

We have a heartbeat

It looks like multiple arguments in the htacess craps my server out. I reduced all those options above to this (which is fine for me, but I pity da fool who needs more):

<IfModule mod_headers.c>
<FilesMatch "\.(php)$">
Header set Access-Control-Allow-Origin: http://mysite.com
Header add Access-Control-Allow-Methods: POST
</FilesMatch>
</IfModule>

All I put in the PHP was

echo "this works at least":

And that came in the response. Once I figure out what’s causing my PHP to fail, I’ll post it.

Again, thanks all!

Zend Guard the problem?

Sooooooooo, sorry guys. Forgot to add that my site’s running Zend Guard. Have a feeling that’s causing it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:08:51+00:00Added an answer on June 14, 2026 at 4:08 pm

    When the client tries to do a CORS request it first sends a “preflight” request to make sure the server supports CORS. If the preflight request passes, then the real request will be send.

    Your server needs to send the right responses to CORS requests. I have a CORS PHP gist that shows how to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.