Let Apache and nginx support cross-domain access

WBOY
Release: 2016-08-08 09:21:56
Original
993 people have browsed it

1. How to make Apache support cross-domain access?
Steps:

  1. Modify httpd.conf, the corresponding directory in windows is: C:wampbinapacheApache2.4.4confhttpd.conf
  2. Delete the comment in front of LoadModule headers_module modules/mod_headers.so
  3. Modify

    Change to:

    That is:
<code><span><</span>Directory <span>/</span><span>></span>
    AllowOverride <span>none</span><span>Require</span><span>all</span> granted
    <span>Header</span><span>set</span> Access<span>-Control</span><span>-Allow</span><span>-Origin</span><span>*</span><span><</span>/Directory<span>></span></code>
Copy after login

If you use the graphical interface to open the headers_module module, please pay attention to the order of the steps
(1) First use the graphical interface to enable the headers_module module function;
(2) Then modify the httpd.conf configuration file and add Header set Access-Control-Allow-Origin *
If the order is wrong, the httpd service cannot be started

2. How to make Nginx support cross-domain?
1. Enter the html directory of nginx
vim ../crossdomain.xml
Specific path: /usr/local/nginx/html/crossdomain.xml
2. Add:

<code><span><?xml version="1.0" encoding="UTF-8"?></span><span><!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"></span><span><<span>cross-domain-policy</span>></span><span><<span>allow-access-from</span><span>domain</span>=<span>"*"</span> /></span><span></<span>cross-domain-policy</span>></span></code>
Copy after login

to crossdomain.xml. The result is:

Note: The default /usr/local/nginx/html/crossdomain.xml does not exist.

The above has introduced how to enable Apache and nginx to support cross-domain access, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!