在Windows中的Apache中启用mod_headers

ezh*_*hil 6 apache webserver dispatcher aem

我试图在Apache中配置Access-Control-Allow-Origin以允许某些域.下面是我的httpd配置

<IfModule mod_headers.c>
   Header set Access-Control-Allow-Origin "*"
</IfModule>
Run Code Online (Sandbox Code Playgroud)

但上面的配置没有做任何事情.听说我们需要启用mod_headers才能使它工作.我运行这个httpd -M命令,发现我的Apache中没有头模块.你能不能告诉我如何启用?

小智 10

这是我的解决方案:

  1. 打开文件httpd.conf"your apache folder"/conf
  2. 在文本编辑器中使用CTRL+ 找到以下行f:#LoadModule headers_module modules/mod_headers.so
  3. 除掉 #
  4. 保存并重新启动您的Apache.