从 Apache 2.2 升级到 Apache 2.4 后,Wordpress 显示永久循环重定向

从 Apache 2.2 升级到 Apache 2.4 后,Wordpress 显示永久循环重定向

我今天将我的 Apache 2.2 网络服务器升级到了 2.4,然后一些 Wordpress 安装开始出现从非 www 到 www 以及从 www 到非 www 的无限循环 :(

删除 .htaccess 没有帮助。

如何解决这个问题?示例域配置:

SetEnvIf X-Forwarded-Proto https HTTPS=1

ServerAdmin [email protected]

ServerName internet.az.pl

ServerAlias www.internet.az.pl

DocumentRoot "/home/admin2/komputery"

DirectoryIndex index.php index.html index.shtml index.htm index.pl index.py index.cgi index.rb default.htm Default.aspx Default.asp

ScriptAlias /cgi-bin/ "/home/admin2/internet.az.pl/cgi-bin/"

<IfModule mod_fastcgi.c>
        Alias /internet.az.pl.0fake "/home/admin2/komputery/internet.az.pl.0fake"
        #FastCGIExternalServer "/home/admin2/komputery/internet.az.pl.0fake" -host 127.0.0.1:52474 -idle-timeout 300 -pass-header Authorization
        FastCGIExternalServer "/home/admin2/komputery/internet.az.pl.0fake" -socket /opt/configs/php-fpm/sock/admin2.sock -idle-timeout 300 -pass-header Authorization
        AddType application/x-httpd-fastphp .php
        Action application/x-httpd-fastphp /internet.az.pl.0fake
        <Files "internet.az.pl.0fake">
                RewriteCond %{REQUEST_URI} !internet.az.pl.0fake
        </Files>
</IfModule>

<Directory "/home/admin2/komputery/">
        AllowOverride All
        <IfVersion < 2.4>
                Order allow,deny
                Allow from all
        </IfVersion>
        <IfVersion >= 2.4>
                Require all granted
        </IfVersion>
        Options +ExecCGI
        <FilesMatch \.(cgi|pl)$>
                SetHandler cgi-script
        </FilesMatch>
</Directory>

<IfModule mod_php5.c>
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i"
        php_admin_value sendmail_from "internet.az.pl"
        Include /home/kloxo/client/admin2/prefork.inc
</IfModule>

<Location "/">
        Allow from all
        Options -Indexes -FollowSymlinks +SymLinksIfOwnerMatch

        <IfModule mod_php5.c>
                php_admin_value open_basedir "/home/admin2:/tmp:/usr/share/pear:/var/lib/php/session/:/home/kloxo/httpd/script:/home/kloxo/httpd/disable/:/usr/bin"
        </IfModule>
</Location>

CustomLog "/home/httpd/internet.az.pl/stats/internet.az.pl-custom_log" combined
ErrorLog "/home/httpd/internet.az.pl/stats/internet.az.pl-error_log"

以及 httpd.conf:

   ServerTokens Prod

ServerRoot "/etc/httpd"

# MR -- must be disable here because can not overrite! -- importance for proxy-to-apache
# Listen 80

Include conf.modules.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel error

<IfModule log_config_module>
        ## MR -- change %h to %a to fix mod_remoteip issue
    LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%a %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    # Alias /webpath /full/filesystem/path
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #AddHandler cgi-script .cgi
    #AddHandler type-map var

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

Alias /error/ "/home/kloxo/httpd/error/"

<IfModule mod_negotiation.c>
    <IfModule mod_include.c>
        <Directory "/home/kloxo/httpd/error/">
            AllowOverride None
            Options IncludesNoExec
            AddOutputFilter Includes html
            AddHandler type-map var
            <IfVersion < 2.4>
                Order allow,deny
                Allow from all
            </IfVersion>
            <IfVersion >= 2.4>
                Require all granted
            </IfVersion>
                LanguagePriority en es de fr
            ForceLanguagePriority Prefer Fallback
        </Directory>

        #ErrorDocument 500 "The server made a boo boo."
        #ErrorDocument 404 /missing.html
        #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
        #ErrorDocument 402 http://www.example.com/subscription_info.html

        ErrorDocument 401 /error/401.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 500 /error/500.html
        ErrorDocument 501 /error/501.html
        ErrorDocument 503 /error/503.html
        ErrorDocument 504 /error/504.html
    </IfModule>
</IfModule>

EnableSendfile on

IncludeOptional conf.d/*.conf

答案1

首先...停止使用IfModule非可选的位。(不确定什么是必需的或不是必需的)它们只有在您有后备方法恢复该模块不存在或未加载时才有用。否则,apache 将启动而不会出现错误...尽管实际上 90% 的配置都不会被加载。

测试并最终修复的快速方法是删除所有语句IfModule,然后重新启动 apache。您几乎肯定会遇到错误。阅读错误日志。查看您遇到的错误(例如无法加载 blah blah)并启用/安装/重建使您的网站正常运行所需的必要模块。

答案2

问题出在 nginx 中——更改行:

proxy_set_header X-Host $var_domain;

proxy_set_header X-Host $host;

解决了问题

相关内容