Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable mod_headers in Apache in Windows

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?

like image 638
ezhil Avatar asked Jan 31 '18 11:01

ezhil


People also ask

How do you check Mod_headers so is enabled?

You can simply use apachectl -M command to list all the enabled modules in Apache web server. Since the output contains a list of all installed modules in Apache, we can pass its output to grep and search for “expires” string. If the output contains “expires_module” it means mod_expires is enabled.

What is Mod_headers?

This module provides directives to control and modify HTTP request and response headers. Headers can be merged, replaced or removed.


1 Answers

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.
like image 102
Michel Neves Avatar answered Sep 19 '22 19:09

Michel Neves