我已经在计算机上安装并运行了apache2,并且在
中有一个文件夹/var/www/html/my-site
我要启用
Header set Access-Control-Allow-Origin "*"
到目前为止,我已经将.htaccess文件放在my-site文件夹中,
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Credentials true
</IfModule>
但是我不确定在哪里为目录启用.htaccess。我确保已加载apache2标头模块,并在apache2.conf文件中放置了一个新目录列表(不确定是否可以使用?),但仍无法使它工作:
<Directory /var/www/html/my-site>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
我不想弄乱添加新站点并可能进行反向代理,所以我只是想能够使该站点正常工作。有可能吗,我在这里做错了吗?
最后,我尝试使用javascript lib axios并跨域运行请求,但是出现错误,这就是我这样做的原因:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://sitethatisdesired.com. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)
答案 0 :(得分:0)
您有错字:
:
您忘记了#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
char a = 'A';
char b = 'B';
//using string class fill constructor
string str3;
str3 = string(1,a) + string(1,b);
cout << str3;
str3.clear();
cout << endl;
//using stringstream
stringstream ss;
ss << a << b;
str3 = ss.str();
cout << str3;
str3.clear();
cout << endl;
//using string push_back
str3.pb(a);
str3.pb(b);
cout << str3;
str3.clear();
cout << endl;
//using string::operator+=
str3+=a;
str3+=b;
cout << str3;
str3.clear();
cout << endl;
//using string::append
str3.append(1,a);
str3.append(1,b);
cout << str3;
str3.clear();
cout << endl;
//using string::insert
str3.insert(0,1,a);
str3.insert(1,1,b);
cout << str3;
str3.clear();
cout << endl;
//using string::replace
str3.replace(0,1,1,a);
str3.replace(1,1,1,b);
cout << str3;
str3.clear();
cout << endl;
return 0;
}