I've added the following at the top of my .htaccess file:

<IfModule mod_headers.c>
    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Headers "Content-Type, Authorization"
    Header always set Access-Control-Allow-Methods "GET,PUT,POST,DELETE"
    Header always set Access-Control-Allow-Credentials true

In order to allow a subdomain-served login screen to do an AJAX Request to the main domain. It works on localhost, but not on the actual server. I've googled around quite a lot but there doesn't seem to be a solution for this. I've already checked through SSH if apache mod_headers was loaded, and the LoadModule line is there on the httpd.conf file.

  • 1
    When you have access to the httpd.conf file please don't use .htaccess files but place your desired settings in the main httpd.conf httpd.apache.org/docs/2.4/howto/htaccess.html#when
    – HBruijn
    Apr 10, 2019 at 14:12
  • Remove the <IfModule> wrapper. Any error? Are .htaccess overrides enabled?
    – MrWhite
    Apr 10, 2019 at 14:19
  • @MrWhite I already tested removing the IfModule but there was no difference nor errors. There's no override line in .htaccess Apr 10, 2019 at 14:24
  • 3
    The appropriate AllowOverride directive needs to be set in the server config before these directives in .htaccess will do anything.
    – MrWhite
    Apr 10, 2019 at 14:26
  • 1
    @MrWhite I've checked and the AllowOverride directive is there. Also, other directices in .htaccess work properly. Apr 11, 2019 at 6:23


You must log in to answer this question.

Browse other questions tagged .