在Mac OS X中为CORS启用apache中的mod_header

use*_*856 1 apache cors

我正在尝试设置我的站点以允许CORS进行跨域脚本编写,但是这似乎需要mod_header在我的.htaccess文件中启用.我没有太多处理apache的经验.

我试图google installing mod_header in apache on mac os但找不到任何东西.

我试过这个user@mymac:~$ httpd -l,这里是目前安装的模块.

  core.c
  prefork.c
  http_core.c
  mod_so.c
Run Code Online (Sandbox Code Playgroud)

有知识的人能告诉我如何mod_header在Mac OS中安装吗?

谢谢

Ton*_*hen 7

我相信你的意思mod_headers.通常它已经作为共享模块安装在apache中.

试试这个:

$ httpd -M |grep header
Run Code Online (Sandbox Code Playgroud)

你应该看到:

Syntax OK
 headers_module (shared)
Run Code Online (Sandbox Code Playgroud)

如果没有,请转到/etc/apache2/httpd.conf,找到下面的行并取消注释

# LoadModule headers_module libexec/apache2/mod_headers.so
Run Code Online (Sandbox Code Playgroud)