Бесконечный цикл перенаправления WordPress при доступе к wp-admin

Я только что перенес свой блог wordpress на новый сервер. я перенастроил файлы конфигурации nginx, и внешний интерфейс отлично работает. Однако, когда я пытаюсь получить доступ к области mywebsite.com/wp-admin, я получаю бесконечный цикл перенаправления, но если я добавляю index.php (mywebsite.com/wp-admin/index.php), он работает. я дергаю себя за волосы, потому что не могу понять, почему nginx так себя ведет

Я уже видел такие проблемы на форуме, но в моем случае файл conf кажется правильным (он такой же, как на моем старом сервере)

Я также отключил все свои плагины (на всякий случай), и у меня такое же поведение.

Здесь вы можете найти мой файл конфигурации nginx

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;
}

Спасибо за помощь


person mahieddine    schedule 29.11.2015    source источник


Ответы (1)


На сервере уже установлен другой экземпляр WordPress. Вам нужно переписать директивы nginx в ISPConfig как:

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; 
               }

}

также включите то же самое в подпапку. Обычно его путь ISPConfig — /home/admispconfig/ispconfig/lib/config.inc.php, или вы можете выполнить поиск на своем сервере

person Ghayel    schedule 29.11.2015
comment
Привет, спасибо за ваше время, нет, у меня нет других экземпляров WordPress на моем сервере. я попытался добавить / после $host$uri, но я все еще сталкиваюсь с той же проблемой :( есть идеи? - person mahieddine; 29.11.2015