首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx返回301而不重写

nginx返回301而不重写
EN

Stack Overflow用户
提问于 2022-06-22 14:20:02
回答 1查看 30关注 0票数 0

我有一个wordpress站点,其配置如下:

代码语言:javascript
复制
ian@ianhobson:/etc/nginx/sites-enabled$ cat thecoachmasternetwork
# Statements for thecoachmasternetwork.com
#
# rewrites of http to https at bottom of file
server {

server_name thecoachmasternetwork.com www.thecoachmasternetwork.com;

listen 80;
fastcgi_read_timeout  300;

root /var/www/thecoachmasternetwork/htsecure;
index index.php;
fastcgi_index index.php;

access_log /var/log/nginx/thecoachmasternetwork.access.log;
# error_log  /var/log/nginx/error.log;
#
location = /favicon.ico {
    log_not_found off;
    access_log off;
}
location ~ \.user\.ini$ {
    deny all;
}
# disallow hot linking to images
location ~ .(gif|png|jpg|jpeg)$ {
    valid_referers none blocked thecoachmasternetwork.com www.thecoachmasternetwork.com;
    if ($invalid_referer) {
        return 403;
    }
}
# serve static files that exist
location / {
    try_files $uri $uri/ /index.php?$args;
}
# send .php files to fastcgi if file exists
location ~ \.php$ {
   # Zero-day exploit defence - http://forum.nginx.org/read.php?2,88845,page=3
   try_files $uri =404;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_param SCRIPT_FILENAME $document_root@fastcgi_script_name;
   fastcgi_param PATH_INFO       $fastcgi_path_info;
   include /etc/nginx/fastcgi.conf;
   fastcgi_pass 127.0.0.1:9000;


 }

}

    # redirects from http -> https
    #server {
    #    if ($host = www.thecoachmasternetwork.com) {
    #        return 301 https://$host$request_uri;
    #    } # managed by Certbot
    
    
    #    if ($host = thecoachmasternetwork.com) {
    #        return 301 https://$host$request_uri;
    #    } # managed by Certbot
    
    
    #    server_name thecoachmasternetwork.com www.thecoachmasternetwork.com;
    #    listen 80;
    #    return 404; # managed by Certbot
    
    #}
    ian@ianhobson:/etc/nginx/sites-enabled$

我找不到重写或返回301。

但是,当我请求根目录或请求/index.php时,访问日志显示一个301重定向到服务器上的另一个站点。这不是default_site,也不是第一个站点。在包含启用/*站点之前,已经在nginx.conf中设置了这些站点。不过,仅在80端口。

我怀疑certbot的证书存在问题(这就是为什么我已经将它切换到端口80,soI可以再次启动它们)。重定向到的站点,在https上,并且看起来很好。

其他可能有用的信息。正确地为/license.txt服务。包含.php 的文件将产生预期的结果。我看不出里面有什么奇怪的东西。我在WP文件中到处找过,没有什么奇怪的地方,但它是一个非常复杂的网站。

error.log里什么都没有。

那么到底发生了什么?

EN

回答 1

Stack Overflow用户

发布于 2022-06-23 10:31:45

原来wordpress在“选项”表中有两行,它们定义了站点和主页的URL。我没有改变这些,是wordpress发布的301。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72717250

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档