Wordpress wp admin重定向循环,再一次
我意识到这个问题以前被问过很多次,但我认为我的问题是独一无二的(但我们不都这么认为吗?../哲学) 我的站点在尝试登录到wp admin时收到重定向循环。如果我使用wp admin/index.php,它可以工作并允许我访问管理区域(链接更改为)。代码在本地和生产服务器上是相同的 我正在运行apache2.4.7、PHP5.3.29和Ubuntu 14.04。这是在升级到WP4.2.1之后开始出现的 我已经按照建议检查了权限和所有权,我按照建议检查了.htaccess和apache2.conf(见下文),我按照建议检查了wp_选项、siteurl/主页设置,我还看到了相同的问题,要求提供更多详细信息,但没有解决 该网站正在本地工作,管理部门也在工作。 生产站点工作正常,但当我尝试wp admin时,生产服务器会给出一个重定向循环。升级到WP 4.2.1后,问题开始出现。 该网站已启用并更新了以下插件:Akismet、多功能搜索引擎优化包、Antispam Bee、AntiVirus、Yoast的谷歌分析、WordPress的谷歌地图、水母计数器小部件、MCE表格按钮和WP响应菜单 我的过程是在本地更新、测试,然后推送到部署服务器。我从那里部署到生产服务器,因此进入生产的唯一代码是来自本地机器的,这是一个简单的过程,没有任何修改或转换 为什么会出现重定向错误? 问题一定是在设置、数据库或配置中…它不能在代码中,因为代码在本地计算机上工作。对吧 好的,我的故障排除步骤(在每一步之后,我都重新启动apache2引擎): 第一个测试:禁用所有插件 测试并收到了相同的重定向循环错误,所以我重新启用了插件 选中wp_选项siteurl和home以验证它们设置是否正确Wordpress wp admin重定向循环,再一次,wordpress,Wordpress,我意识到这个问题以前被问过很多次,但我认为我的问题是独一无二的(但我们不都这么认为吗?../哲学) 我的站点在尝试登录到wp admin时收到重定向循环。如果我使用wp admin/index.php,它可以工作并允许我访问管理区域(链接更改为)。代码在本地和生产服务器上是相同的 我正在运行apache2.4.7、PHP5.3.29和Ubuntu 14.04。这是在升级到WP4.2.1之后开始出现的 我已经按照建议检查了权限和所有权,我按照建议检查了.htaccess和apache2.conf(
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以确保设置正确(我不确定哪些设置覆盖了其他设置):
关闭apache2.conf中的mod_重写
sudo a2dismod rewrite
相同的结果,因此重新启用:
sudo a2enmod rewrite
我的网站根目录下的My.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
我需要帮助确定此重定向的来源。好的,让我们在这里尝试一些东西:
siteurlhttp://example.com/site服务器名www.example.com
时在数据库中?如果site
文件夹类似于public
,则URI不应访问该文件夹。所以你的“站点URI”和“主页”应该是http://example.com
谢谢我通过简化网站的可用配置解决了这个问题。这就是我使用的:
<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>
ServerName example.org
ServerAlias example.com
ServerAlias示例.net
DocumentRoot/var/www/example.org/site
DirectoryIndex.php index.html
选项索引跟随SYMLINKS ExecCGI
允许超越所有
要求所有授权
ErrorLog${APACHE\u LOG\u DIR}/example\u error.LOG
CustomLog${APACHE\u LOG\u DIR}/example\u access.LOG组合
现在在访问wp admin时没有重定向 我通过将wp admin中的所有文件权限从777更改为644,文件夹755进行了修复。检查您的权限您的站点的URL为,因此我猜您的站点位于“/site”文件夹中。你为什么不那样访问wp admin
http://example.com/site/wp-admin.php
?@Samuel感谢您的回复。wp admin是一个文件夹,而不是一个文件;没有wp-admin.php文件,所以我在尝试时遇到了404错误。感谢您指出这些,Samuel。我做了您建议的更改(修复了siteurl和home条目,并注释掉了重写规则),但仍然有一个重定向循环。哦,error.log只有许多条目,如“…AH01626:Require all grated的授权结果:grated”,但没有其他有趣的内容。下面是一个示例:[Fri May 08 10:27:54.560217 2015][authz_core:debug][pid 30657]mod_authz_core.c(802):[client 91.220.230.20:56061]AH01626:授权结果:授予[Fri May 08 10:27:54.745877 2015][authz_core:debug][pid 30657]mod_authz_core.c(802):[client 91.220.230.20:56061]AH01626:要求所有授予的授权结果:授予[Fri May 08 10:27:54.745931 2015][authz_core:debug][pid 30657]mod_authz_core.c(802):[client 91.220.230.20:56061]AH01626:授权结果:granted您是否尝试禁用所有插件?如果没有,请全部禁用它们这是我尝试的第一件事。我将尝试通过在.htaccess中放置重定向来解决此问题,以强制wp admin到wp admin/index.php。您好,您能否对此给出更多说明?是否可以在htaccess中执行此操作?我没有能够找到.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
# 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>
<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://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
<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>