简体   繁体   English

访问wp-admin时的WordPress无限重定向循环

[英]WordPress infinite redirect loop when accessing wp-admin

I've just moved my wordpress blog on a new server. 我刚刚将我的wordpress博客移到了新服务器上。 i reconfigured nginx conf files and the front end works great. 我重新配置了nginx conf文件,并且前端工作得很好。 However when i try to access mywebsite.com/wp-admin area i get an infinite redirect loop but if i add index.php (mywebsite.com/wp-admin/index.php) it works. 但是,当我尝试访问mywebsite.com/wp-admin区域时,会遇到无限重定向循环,但是如果我添加index.php(mywebsite.com/wp-admin/index.php),它将起作用。 i'm pulling my hair because i can't figure out why nginx behave like that 我拉我的头发,因为我不知道为什么Nginx会那样

I've already seen problems like this on the forum but in my case the conf file seem correct (its the same as on my old server) 我已经在论坛上看到过类似的问题,但就我而言,conf文件似乎正确(与我的旧服务器上的一样)

I also disabled all my plugins (just in case) and i got the same behaviour 我也禁用了所有插件(以防万一),并且得到了相同的行为

Here you can fin my nginx conf file 在这里您可以查找我的Nginx conf文件

server {
    listen 80;
    server_name mywebsite.com www.mywebsite.com;
    root /home/mywebsite;
    index /index.php;
    access_log /var/log/nginx/www.mywebsite.com.access.log;
    error_log /var/log/nginx/www.mywebsite.com.error.log;
    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). 
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~ /\. {
    deny all;
    } 

    # Deny access to any files with a .php extension in the uploads directory
    # Works in sub-directory installs and also in multisite network
    # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
    location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
    } 

    # WordPress single site rules.
    # Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
    try_files $uri $uri/ /index.php?$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri permanent;

# Add trailing slash to */wp-admin requests.
#rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       access_log off; log_not_found off; expires max;
}

# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;

#ss all .php files onto a php-fpm/php-fcgi server.
location ~ [^/]\.php(/|$) {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)
    #fastcgi_index /index.php;
    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/mywebsite/dynamic$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
#   fastcgi_intercept_errors on;
}

Thank you for you help 谢谢你的帮助

There is other wordpress instance already installed on the server. 服务器上已经安装了其他wordpress实例。 You need to rewrite nginx directives in ISPConfig as: 您需要将ISPConfig中的nginx指令重写为:

location / {
                try_files $uri $uri/ /index.php?$args;

               # Add trailing slash to */wp-admin requests.
               rewrite /wp-admin$ $scheme://$host$uri/ permanent;

               location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
               }
               # Deny public access to wp-config.php
               location ~* wp-config.php { 
                    deny all; 
               }

}

also include the same in subfolder. 在子文件夹中也包含相同的内容。 Usually its ISPConfig path is /home/admispconfig/ispconfig/lib/config.inc.php or you can search on your server 通常,其ISPConfig路径为/home/admispconfig/ispconfig/lib/config.inc.php,或者您可以在服务器上搜索

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM