nginx - 403 显示与 WWW [Nginx]
问题描述
我只能使用此域名访问该站点:
https://example.com [Working]
那是我可以访问它,但如果我添加www
;我得到403屏幕。
这是我的 Nginx 配置文件。文件:
server {
listen 80;
server_name domain.com;
rewrite_log on;
client_max_body_size 1000M;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
if (!-e $request_filename){
rewrite ^/(.+)/(.+)$ /index.php?id=$1&cmd=$2 last;
rewrite ^/(.+)$ /index.php?id=$1 last;
}
}
location ~* \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
解决方案
我自己找到了答案。其实,答案很简单。
server_name domain.com;
至 server_name domain.com www.domain.com;
所以我要解决这个问题。
推荐阅读
- reactjs - 页面刷新时antd表单字段中不显示数据?
- pandas - 将高数据框转换为宽数据框熊猫
- javascript - 三反斜杠“\\\”是什么意思?
- ansible - 带有_items列表的Ansible过滤器
- ruby-on-rails - 使用 collection_select 通过 has_many 和 belongs_to 关联在预订中保存两个类的 ID 保存时会抛出错误“必须存在”
- wso2 - 使用本地 API 端点处理消息处理器问题
- c# - Windows 窗体组合框:在项目选择后显示自定义对象
- r - Dockerized Neo4J 因“不支持的 uri 方案:http”而失败
- c++ - 未找到 QML 模块
- python - 在鼠标事件中的 Pyhook 回调方法中返回 False 不会暂停应用程序