如何在apache2中允许跨域请求 [英] How to allow Cross domain request in apache2
本文介绍了如何在apache2中允许跨域请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的配置文件.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName localhost:80
DocumentRoot /var/www/XXX
<Directory />
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory /var/www/qvbn-app-web-ctrl>
Options FollowSymLinks
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
Header set Access-Control-Allow-Origin "*"
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
当我尝试重新加载apache2时,iT发出错误消息:
When i am trying to reload apache2 iT is giving error as :
Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
我不知道如何启用CORS.我遵循了这一点: http://enable-cors.org/server_apache.html
I don't know how to enable CORS. I followed this: http://enable-cors.org/server_apache.html
推荐答案
OS=GNU/Linux Debian
Httpd=Apache/2.4.10
更改/etc/apache2/apache2.conf
Change in /etc/apache2/apache2.conf
<Directory /var/www/html>
Order Allow,Deny
Allow from all
AllowOverride all
Header set Access-Control-Allow-Origin "*"
</Directory>
添加/激活模块
a2enmod headers
重新启动服务
/etc/init.t/apache2 restart
这篇关于如何在apache2中允许跨域请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文