【发布时间】:2017-07-31 04:45:50
【问题描述】:
我正在尝试启用对我的 Apache2 Web 服务器上的目录的 CORS 访问。我启用了 .htaccess 文件并添加了一行,旨在启用对目录的 CORS 访问。
Header set Access-Control-Allow-Origin: "*"
使用该行保存 .htaccess 文件后,尝试访问目录时出现 500 内部服务器错误 (http://williamgreen.hopto.org/audio/)。
有什么想法吗?我的标题不正确吗? 谢谢。
Apache2 错误日志:
[2017 年 3 月 9 日星期四 15:02:15.118686] [mpm_event:notice] [pid 2668:tid 547718139904] AH00489:Apache/2.4.18 (Ubuntu) 已配置 -- 恢复正常操作
[Thu Mar 09 15:02:15.119080 2017] [core:notice] [pid 2668:tid 547718139904] AH00094:命令行:'/usr/sbin/apache2'
[2017 年 3 月 9 日星期四 19:27:09.148771] [mpm_event:notice] [pid 2668:tid 547718139904] AH00491:捕获 SIGTERM,正在关闭
[2017 年 3 月 9 日星期四 19:27:10.339942] [mpm_event:notice] [pid 14385:tid 548172222464] AH00489:Apache/2.4.18 (Ubuntu) 已配置 -- 恢复正常操作
[Thu Mar 09 19:27:10.340300 2017] [core:notice] [pid 14385:tid 548172222464] AH00094:命令行:'/usr/sbin/apache2'
[2017 年 3 月 9 日星期四 19:39:47.583449] [mpm_event:notice] [pid 14385:tid 548172222464] AH00491:捕获 SIGTERM,正在关闭
[2017 年 3 月 9 日星期四 19:39:47.776394] [mpm_event:notice] [pid 14915:tid 548543827968] AH00489: Apache/2.4.18 (Ubuntu) 已配置 -- 恢复正常操作
[2017 年 3 月 9 日星期四 19:39:47.776776] [core:notice] [pid 14915:tid 548543827968] AH00094:命令行:'/usr/sbin/apache2'
[Thu Mar 09 19:39:51.201462 2017] [core:alert] [pid 14919:tid 548512096688] [client 73.15.129.28:57278] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义,引用者:http://williamgreen.hopto.org/audio/Music/
[Thu Mar 09 19:39:51.204818 2017] [core:alert] [pid 14918:tid 548528873904] [client 73.15.129.28:57280] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义,引用者:http://williamgreen.hopto.org/audio/Music/
[Thu Mar 09 19:39:55.389791 2017] [core:alert] [pid 14918:tid 548520485296] [client 73.15.129.28:57279] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义
[Thu Mar 09 19:40:02.264113 2017] [core:alert] [pid 14918:tid 548512096688] [client 73.15.129.28:57283] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义
[Thu Mar 09 19:40:03.735693 2017] [core:alert] [pid 14919:tid 548503708080] [client 73.15.129.28:57284] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义
[Thu Mar 09 19:40:04.183378 2017] [core:alert] [pid 14918:tid 548503708080] [client 73.15.129.28:57285] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义
[Thu Mar 09 19:40:04.527274 2017] [core:alert] [pid 14919:tid 548520485296] [client 73.15.129.28:57286] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义
[Thu Mar 09 19:40:04.846900 2017] [core:alert] [pid 14919:tid 548495319472] [client 73.15.129.28:57287] /var/www/html/audio/.htaccess: 无效的命令“标题”,也许由未包含在服务器配置中的模块拼写错误或定义
【问题讨论】:
-
您在 apache 错误日志中看到了什么?
-
我正在补充我的答案。我有游泳练习,所以我必须离开。我现在没有时间阅读它:(
-
“无效命令 'Header',可能拼写错误或由未包含在服务器配置中的模块定义”... 所以 headers 模块未启用,您需要启用它在系统 Apache 配置文件中或使用
a2enmod headers
标签: php apache .htaccess apache2