Enable mod_headers in Apache in Windows

ezhil picture ezhil · Jan 31, 2018 · Viewed 16.3k times · Source

I am trying to configure Access-Control-Allow-Origin in Apache to allow certain domains. Below is my httpd configuration

<IfModule mod_headers.c>
   Header set Access-Control-Allow-Origin "*"
</IfModule>

But the above config is not doing anything. Heard that we need to enable mod_headers to make it work. I run this httpd -M command and observed that header module is not present in my Apache. Can you anyone pls tell me how to enable?

Answer

Michel Neves picture Michel Neves · Jun 30, 2018

Here is my solution:

  1. Open the file httpd.conf at "your apache folder"/conf
  2. Find the following line using CTRL+f in your text editor: #LoadModule headers_module modules/mod_headers.so
  3. Remove the #
  4. Save and restart your apache.