Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Disable Access-Control-Allow-Origin from Apache or htaccess?

Discussion in 'EasyApache' started by Muhammad_Adel, Feb 6, 2018.

  1. Muhammad_Adel

    Muhammad_Adel Registered

    Joined:
    Feb 6, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Egypt
    cPanel Access Level:
    Root Administrator
    in my local machine when I try to send request via ajax using cross domains the request doesn't complete I added this options to .htaccess file

    Header always set Access-Control-Allow-Origin "https://accepted-domain"
    Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
    Header always set Access-Control-Max-Age "1000"
    Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"

    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^(.*)$ $1 [R=200,L]

    after that every things worked just fine but when I uploaded this to my cPanel server the request didn't completed but when I removed this lines from the .htaccess file every thing worked just fine

    the question is how to disable this Access-Control-Allow-Origin in my cPanel host to define it with the domain I want to accept only
    Note
    when I sent the request on my cPanel hosting the response was this message

    Failed to load http://receiver-domain.com/create.php: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin 'http://sender-domain.com' is therefore not allowed access.

    which mean the Access-Control-Allow-Origin has been set somewhere else
     
  2. cPWilliamL

    cPWilliamL cP Technical Analyst II
    Staff Member

    Joined:
    May 15, 2017
    Messages:
    257
    Likes Received:
    29
    Trophy Points:
    103
    Location:
    America
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice