programing

Wordpress wp-admin 리다이렉트루프 다시 시작

oldcodes 2023. 3. 10. 22:45
반응형

Wordpress wp-admin 리다이렉트루프 다시 시작

전에도 여러 번 물어봤던 질문이지만, 내 문제는 특이한 것 같아(다들 그렇게 생각하지 않니? /철학)

wp-admin 로그인 시도 시 사이트에 리다이렉트루프가 발생합니다.wp-admin/index.http://example/wp-login.php?redirect_to=http3A%2Fexample%2Fexample%2Fex.php&reauth=1로 링크가 변경됩니다.코드는 로컬 및 프로덕션 서버에서 동일합니다.

apache 2.4.7, PHP 5.3.29, Ubuntu 14.04를 실행하고 있습니다.이는 WP4.2.1로 업그레이드한 후 발생하기 시작했습니다.

여기에 제시된 권한과 소유권을 확인했고, 여기에 제시와 같이 .htaccess와 apache2.conf(아래 참조)를 확인했으며, 여기에 제시된 바와 같이 wp_options, siteurl/home 설정을 확인했습니다.또, 같은 질문에 대해서는, 자세한 것은 이쪽에서 확인했지만, 수정은 없었습니다.

사이트는 로컬로 동작하고 있으며 admin 섹션도 동작합니다.생산 사이트는 정상적으로 동작하지만 wp-admin을 시도하면 생산 서버가 리다이렉트 루프를 발생시킵니다.WP 4.2.1로 업그레이드한 후 문제가 발생하였습니다.이 사이트에는 다음 플러그인이 활성화되어 있으며 최신 플러그인이 있습니다.Akismet, All-in-One SEO 팩, Anti-One Bee, AntiVirus, Google Analytics by Yoast, Google Maps for WordPress, 젤리피시 카운터 위젯, MCE 테이블 버튼 및 WP 응답 메뉴.

이 프로세스는 로컬에서 업데이트하고 테스트한 후 배포 서버에 푸시하는 것입니다.거기서부터 실전 가동 서버에 도입하고 있기 때문에, 실전 가동에 들어가는 코드는 로컬 머신의 코드 뿐이며, 변경이나 변환은 일절 실시하지 않습니다.

리다이렉트 에러가 발생하는 이유는 무엇입니까?설정, 데이터베이스 또는 구성에 문제가 있을 수 있습니다.코드는 제 머신에서 로컬로 동작하기 때문에 코드에 문제가 있을 수 없습니다.그렇죠?

문제 해결 단계(각 단계 후 apache2 엔진을 다시 시작):

첫 번째 테스트: 모든 플러그인을 비활성화합니다.

같은 리다이렉트루프 에러를 테스트해 수신했기 때문에, 플러그인을 재차 유효하게 했습니다.

wp_options siteurl과 home이 올바르게 설정되어 있는지 확인.

mysql> select * from wp_options where option_id = '37' or option_id='1';
+-----------+-------------+--------------------------------------------------+----------+
| option_id | option_name | option_value | autoload |
+-----------+-------------+--------------------------------------------------+----------+
| 1 | siteurl | http://example.com/site | yes |
| 37 | home | http://example.com/site | yes |
+-----------+-------------+--------------------------------------------------+----------+
2 rows in set (0.00 sec)

wp-config도 확인.php 설정이 올바른지 확인합니다(어느 쪽이 다른 쪽보다 우선하는지 잘 모르겠습니다).

define('WP_SITEURL', 'http://'.$_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://'.$_SERVER['HTTP_HOST']);

apache2.conf의 mod_rewrite를 해제.

sudo a2dismod rewrite

같은 결과, 재활성화:

sudo a2enmod rewrite

사이트의 루트에 있는 .htaccess 파일이 기본값입니다.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

그래서 나는 엔진 리라이트 지시사항을 코멘트하고 재테스트를 했다.

# BEGIN WordPress
<IfModule mod_rewrite.c>
#RewriteEngine On
#RewriteBase /
#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
</IfModule>
# END WordPress

변화가 없다.정상으로 돌아왔습니다.코드에는 wp-content/plugins/akismet/.htaccess 이외의 .htaccess 파일은 없습니다.

다음은 apache2.conf 파일입니다.

# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
# /etc/apache2/
# |-- apache2.conf
# | `-- ports.conf
# |-- mods-enabled
# | |-- *.load
# | `-- *.conf
# |-- conf-enabled
# | `-- *.conf
# `-- sites-enabled
# `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
# together by including all remaining configuration files when starting up the
# web server.
#
# * ports.conf is always included from the main configuration file. It is
# supposed to determine listening ports for incoming connections which can be
# customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
# directories contain particular configuration snippets which manage modules,
# global configuration fragments, or virtual host configurations,
# respectively.
#
# They are activated by symlinking available configuration files from their
# respective *-available/ counterparts. These should be managed by using our
# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
# their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
# the default configuration, apache2 needs to be started/stopped with
# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
# work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
Mutex file:${APACHE_LOCK_DIR} default

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

# added the following to enable fastcgi
#<IfModule mod_fastcgi.c>
# AddHandler php5-fcgi .php
# Action php5-fcgi /php5-fcgi
# Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
# FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
# <Directory /usr/lib/cgi-bin>
# Require all granted
# </Directory>
#</IfModule>

다음은 사이트에서 사용할 수 있는 conf 파일입니다.

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerAlias www.example.com
ServerAlias another.example.com
ServerName example.com

ServerAdmin support@example.com
DocumentRoot /var/www/example.com/site
DirectoryIndex /index.php /index.html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
LogLevel debug

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# SuexecUserGroup triadmin triadmin

<Directory /var/www/example.com/site>
AllowOverride All
Options +ExecCGI +FollowSymlinks
Order allow,deny
Allow from all
</Directory>
# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteOptions inherit
#
# RewriteCond %{HTTP_HOST} ^example\.com
# RewriteRule ^(.*)$ http://www.example.com%{REQUEST_URI} [R=301,L]
# </IfModule>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
#<VirtualHost 45.55.176.172:443>
#SuexecUserGroup triadmin triadmin
ServerName www.example.com
ServerAlias example.com
ServerAdmin support@example.com
DocumentRoot /var/www/example.com/site
<Directory /var/www/example.com/site>
AllowOverride All
Options +ExecCGI +FollowSymlinks
Order allow,deny
Allow from all
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteOptions inherit

RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ https://www.example.com%{REQUEST_URI} [R=301,L]
</IfModule>

# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
# SSLEngine on
# SSLCertificateFile /etc/ssl/apache/example/your_cert_name_here.crt
# SSLCertificateKeyFile /etc/ssl/apache/example/your_cert_key_here.key
# SSLCertificateChainFile /etc/ssl/apache/example/your_cert_chain_here.crt

<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>

BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

헤더 체크 도구(http://www.internetmarketingninjas.com/header-checker/):

http://example.com/wp-admin - 301 Moved Permanently
http://example.com/wp-admin/ - 302 Found
http://example.com/wp-admin/ - 302 Found
…..removed 16 identical responses for brevity….
http://example.com/wp-admin/ - 302 Found

이 리다이렉트가 어디서 왔는지 알아내는 데 도움이 필요해요.

wp-admin의 모든 파일 권한을 777에서 644, 폴더 755로 변경하여 수정하였습니다.사용 권한 확인

사이트에서 사용 가능한 구성을 단순화함으로써 이 문제를 해결할 수 있었습니다.사용법은 다음과 같습니다.

<VirtualHost *:80>
    ServerName     example.org
    ServerAlias    example.com
    ServerAlias    example.net
    DocumentRoot  /var/www/example.org/site

    DirectoryIndex  index.php index.html

    <Directory /var/www/example.org/site>
        Options Indexes FollowSymLinks ExecCGI
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog  ${APACHE_LOG_DIR}/example_error.log
    CustomLog ${APACHE_LOG_DIR}/example_access.log combined

</VirtualHost>

이제 wp-admin에 접속할 때 리다이렉트가 없습니다!

여기서 몇 가지 작업을 수행해 보겠습니다.

  1. 넌 왜 가지고 있니?siteurl http://example.com/site해야 합니다.ServerName www.example.comsite는 「」와 같은 것입니다.publicURI를 사용합니다.URI'와은 'site URI'로 해야 합니다.http://example.com

  2. 여기서 http를 https로 다시 쓰시겠습니까?

    RewriteCond %{HTTP_HOST} ^example.com RewriteRule ^(.*)$ https://www.example.com%{REQUEST_URI} [R=rewrite,L]

왜요? 제거한 후 확인해 주시겠어요?

그래도 문제가 해결되지 않으면 apache error.log를 확인하고 여기서 출력을 인쇄하십시오.

감사해요.

언급URL : https://stackoverflow.com/questions/30058647/wordpress-wp-admin-redirect-loop-yet-again

반응형