跨域,通過Apache本地伺服器除錯執行

2021-07-25 12:29:52 字數 1217 閱讀 1749

mui.ajax(url,

},error:function

(xhr,type,errorthrown)

});

以上是乙個mui框架內的**片段,做到能在瀏覽器直接執行即可,當然url是跨域了。

跨域是指兩個頁面之間 二級網域名稱、埠(得知http 80 , https 443)、協議(直觀的 http , https) 只要有乙個不相同即為跨域。

解決跨域的方法有很多,但是需要伺服器的配合。

require

all granted(注意apache2.4是這個)

order

deny,allow

allow

from all(2.2是這兩個)

關於httpd-vhosts.conf檔案的配置

include conf/extra/httpd-vhosts.conf取消注釋,上面寫著virtual hosts(虛擬主機)。

取消以下httpd.conf的注釋,

配置反向**

#反向**設定

servername

localhost

documentroot

"e:\documents\***"

options

indexes followsymlinks

allowoverride

allrequire

all granted(同理2.2看上面)

proxyrequests

offrequire

all granted

#可配置多個

#訪問的時候就不能用全url了,從/project/開始,前面的http://ip_address不要。相當於識別到路徑中有/project時,會轉到http://ip_address/project訪問。

apache伺服器跨域設定

在需要允許跨域訪問的伺服器的配置檔案 httpd.conf新增如下內容 loadmodule headers module modules mod headers.so allowoverride none require all granted header set access control ...

跨域請求 Apache 伺服器配置

1.修改伺服器配置檔案 options followsymlinks allowoverride all require all granted header set access control allow origin 2.編輯httpd.conf 找下面這行,把 去掉,目的是開啟apache頭...

跨域請求 Apache 伺服器配置的方法

1.修改伺服器配置檔案 require al程式設計客棧l granted header set access control allow origi 2.編輯httpd.conf 找下面這行,把 去掉,目的是開啟apache頭資訊自定義模組 loadmodule headers module mo...