Apache问题?默认的WordPress .htaccess重写导致重定向到AlmaLinux(9.1)默认页面

pgpifvop  于 2023-03-30  发布在  Apache
关注(0)|答案(1)|浏览(211)

我真的可以做一些帮助这里请.我认为这是一个Apache的问题,而不是WordPress的问题.如果我允许.htaccess进程重写我的WordPress网站通过添加AllowOverride FileInfo到https conf文件,我的WordPress网站都重定向到AlmaLinux默认页面.这里是怎么回事?
下面是httpd.conf:

ServerRoot "/etc/httpd"
    Listen *:80 http
    Include conf.modules.d/*.conf
    User apache
    Group apache
    ServerAdmin root@localhost
    ServerName mrtesty.net
    
    <Directory />
        AllowOverride none
        Require all denied
    </Directory>
    
    DocumentRoot "/var/www/html"
    
    <Directory "/var/www">
        AllowOverride None
        Require all granted
    </Directory>
    
    <Directory "/var/www/html">
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
    
    <IfModule dir_module>
        DirectoryIndex index.html index.htm index.php
    </IfModule>
    
    <Files ".ht*">
        Require all denied
    </Files>
    
    ErrorLog "logs/error_log"
    LogLevel warn
    
    <IfModule log_config_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
        LogFormat "%h %l %u %t \"%r\" %>s %b" common
        <IfModule logio_module>
            LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
        </IfModule>
        CustomLog "logs/access_log" combined
    </IfModule>
    
    <IfModule alias_module>
        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
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
    </IfModule>
    
    AddDefaultCharset UTF-8
    
    <IfModule mime_magic_module>
        MIMEMagicFile conf/magic
    </IfModule>
    
    EnableSendfile on
    
    IncludeOptional conf.d/*.conf
    
    # #################
    # 
    # VirtualHosts now in     /etc/httpd/conf.d/vhosts.conf
    # SSL VirtualHosts now in /etc/httpd/conf.d/vhosts-le-ssl.conf
    # 
    # #################
    
    KeepAlive on
    TraceEnable off

下面是我的welcome.conf,如果根URL没有默认索引页,它将提供AlmaLinux默认页:

<LocationMatch "^/+$">
        Options -Indexes
        ErrorDocument 403 /.noindex.html
    </LocationMatch>
    
    <Directory /usr/share/httpd/noindex>
        AllowOverride None
        Require all granted
    </Directory>
    
    Alias /.noindex.html /usr/share/httpd/noindex/index.html
    Alias /poweredby.png /usr/share/httpd/icons/apache_pb3.png
    Alias /system_noindex_logo.png /usr/share/httpd/icons/system_noindex_logo.png

下面是我的ssl.conf文件:

Listen 443 https
    SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
    SSLSessionCache         shmcb:/run/httpd/sslcache(512000)
    SSLSessionCacheTimeout  300
    SSLCryptoDevice builtin
    <VirtualHost _default_:443>
        ErrorLog logs/ssl_error_log
        TransferLog logs/ssl_access_log
        LogLevel warn
        SSLEngine on
        SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
        SSLHonorCipherOrder on
        SSLCipherSuite PROFILE=SYSTEM
        SSLProxyCipherSuite PROFILE=SYSTEM
        SSLCertificateFile /etc/letsencrypt/live/mrtesty.net/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mrtesty.net/privkey.pem    
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory "/var/www/cgi-bin">
            SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch "MSIE [2-5]" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
        CustomLog logs/ssl_request_log \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    </VirtualHost>

下面是我的vhosts.conf条目的网站问题:

<VirtualHost *:80>
        DocumentRoot "/var/www/www.mysite.org"
        ServerName www.mysite.org
        ServerAlias mysite.org
        <Directory "/var/www/www.mysite.org">
            AllowOverride FileInfo
            allow from all
            Options None
            Require all granted
        </Directory>
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =mysite.org [OR]
        RewriteCond %{SERVER_NAME} =www.mysite.org
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>

下面是我的vhosts-le-ssl.conf条目:

<IfModule mod_ssl.c>
        <VirtualHost *:443>
            DocumentRoot "/var/www/www.mysite.org"
            ServerName www.mysite.org
            ServerAlias mysite.org
            <Directory "/var/www/www.mysite.org">
    
                ###########################################
                # IF I UNCOMMENT THE BELOW OUT, IT BREAKS #
                #                                         #
     
                #AllowOverride FileInfo
    
                allow from all
                Options None
                Require all granted
            </Directory>
            Include /etc/letsencrypt/options-ssl-apache.conf
            SSLCertificateFile /etc/letsencrypt/live/www.mysite.org/fullchain.pem
            SSLCertificateKeyFile /etc/letsencrypt/live/www.mysite.org/privkey.pem
        </VirtualHost>
    </IfModule>

这是我的WordPress网站.htaccess文件,如果我取消上面的AllowOverride FileInfo注解,它就会被处理,然后它会通过将所有内容重定向到AlmaLinux默认页面来破坏WordPress。

# BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

还有其他的conf文件,但我没有看到任何相关的

谢谢你这么多提前为任何人谁可以把我从这个。

nfs0ujit

nfs0ujit1#

我应该在一开始就查看Apache错误日志。我只是这样做并发现:
[Wed Mar 29 23:17:59.234743 2023] [rewrite:error] [pid 133333:tid 133444] [client 81.11.11.11:53583] AH00670:选项FollowSymLinks和SymLinksIfOwnerMatch都是关闭的,因此RewriteRule指令也被禁止,因为它具有类似的规避目录限制的能力:/变量/www/www.mysite.com/
搜索我们看到的错误:如果您的服务器设置为关闭FollowSymLinks和SymLinksIfOwnerMatch,则重写规则将停止工作
就这么简单!
所以我在Apache conf文件中查看了我所有的站点并进行了更改:
选项无
致:
选项SymLinksIfOwnerMatch
固定

相关问题