Enable mod_headers in Apache in Windows
Asked Answered
G

1

14

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?

General answered 31/1, 2018 at 11:28 Comment(0)
W
21

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.
Wishywashy answered 29/6, 2018 at 23:54 Comment(4)
This worked for me in 2019! I'm using Avada theme on localhost. Is the mod_headers thing only an issue with WAMP?Zielinski
Don't think so, @EricHepperle-CodeSlayer2010 - there are ways to install Apache on Windows other than WAMP, mod_headers and other modules are a fairly common thing and if or if not they are activated by default / the installations' owners, is up to whoever setups / administrates the installation.Cognizance
Very useful notePeckham
On CentOS 8 there is nothing for #LoadModule headers_module modules/mod_headers.so and a search of modules shows "headers_mod" with no further reference.Peddada

© 2022 - 2024 — McMap. All rights reserved.