简体   繁体   English

为什么我的 Apache2 .htaccess 文件 CORS 标头导致 500 内部服务器错误?

[英]Why is my Apache2 .htaccess file CORS header causing a 500 internal server error?

I am attempting to enable CORS access to a directory on my Apache2 web server.我正在尝试启用对 Apache2 Web 服务器上的目录的 CORS 访问。 I enabled .htaccess file and added a line which is meant to enable CORS access to the directory.我启用了 .htaccess 文件并添加了一行,旨在启用对目录的 CORS 访问。

Header set Access-Control-Allow-Origin: "*"

After saving the .htaccess file with that line, I get a 500 internal server error when attempting to access the directory ( http://williamgreen.hopto.org/audio/ ).使用该行保存 .htaccess 文件后,尝试访问目录 ( http://williamgreen.hopto.org/audio/ ) 时出现 500 内部服务器错误。

Any ideas?有任何想法吗? Is my header incorrect?我的标题不正确吗? Thank you.谢谢你。

Apache2 error.log: Apache2 错误日志:

[Thu Mar 09 15:02:15.118686 2017] [mpm_event:notice] [pid 2668:tid 547718139904] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations [Thu Mar 09 15:02:15.118686 2017] [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: Command line: '/usr/sbin/apache2' [Thu Mar 09 15:02:15.119080 2017] [core:notice] [pid 2668:tid 547718139904] AH00094:命令行:'/usr/sbin/apache2'
[Thu Mar 09 19:27:09.148771 2017] [mpm_event:notice] [pid 2668:tid 547718139904] AH00491: caught SIGTERM, shutting down [Thu Mar 09 19:27:09.148771 2017] [mpm_event:notice] [pid 2668:tid 547718139904] AH00491:捕获 SIGTERM,关闭
[Thu Mar 09 19:27:10.339942 2017] [mpm_event:notice] [pid 14385:tid 548172222464] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations [Thu Mar 09 19:27:10.339942 2017] [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: Command line: '/usr/sbin/apache2' [Thu Mar 09 19:27:10.340300 2017] [core:notice] [pid 14385:tid 548172222464] AH00094:命令行:'/usr/sbin/apache2'
[Thu Mar 09 19:39:47.583449 2017] [mpm_event:notice] [pid 14385:tid 548172222464] AH00491: caught SIGTERM, shutting down [Thu Mar 09 19:39:47.583449 2017] [mpm_event:notice] [pid 14385:tid 548172222464] AH00491:捕获 SIGTERM,关闭
[Thu Mar 09 19:39:47.776394 2017] [mpm_event:notice] [pid 14915:tid 548543827968] AH00489: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations [Thu Mar 09 19:39:47.776394 2017] [mpm_event:notice] [pid 14915:tid 548543827968] AH00489: Apache/2.4.18 (Ubuntu) 配置——恢复正常操作
[Thu Mar 09 19:39:47.776776 2017] [core:notice] [pid 14915:tid 548543827968] AH00094: Command line: '/usr/sbin/apache2' [Thu Mar 09 19:39:47.776776 2017] [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration, referer: http://williamgreen.hopto.org/audio/Music/ [2017 年 3 月 9 日星期四 19:39:51.201462] [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration, referer: http://williamgreen.hopto.org/audio/Music/ [2017 年 3 月 9 日星期四 19:39:51.204818] [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration [2017 年 3 月 9 日星期四 19:40:02.264113] [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration [2017 年 3 月 9 日星期四 19:40:03.735693] [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration [2017 年 3 月 9 日星期四 19:40:04.183378] [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration [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: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration [2017 年 3 月 9 日星期四 19:40:04.846900] [core:alert] [pid 14919:tid 548495319472] [client 73.15.129.28:57287] /var/www/html/audio/.htaccess,可能是无效的命令'头文件'由服务器配置中未包含的模块拼写错误或定义

You dont have the headers module installed.您没有安装 headers 模块。 With apache2, just run a2enmod headers and then sudo service apache2 restart and it will install the headers module automatically.使用 apache2,只需运行a2enmod headers然后sudo service apache2 restart它将自动安装 headers 模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM