AH00124:由于可能的配置错误,请求超出了10个内部重定向的限制

问题描述 投票:0回答:1

[当有人访问我网站上的商店页面时,我一直在我的apache日志中看到此错误,我尝试删除htaccess并使用.php?s = $ var,但我仍然遇到相同的错误,所以我认为这是可以做的与apache配置文件,与htaccess文件无关,无论如何,这里是

htaccess:

RewriteEngine on
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.example.com%{REQUEST_URI} [L,R=301]

RewriteCond %{THE_REQUEST} //
RewriteRule ^(.*)$ /$1 [L,R=301]

RewriteRule ^home/?$ home.php  [NC]

RewriteCond %{THE_REQUEST} /shop\?c=([^&\s]+)&s=([^&\s]+)&s2=([^&\s]+)&b=([^&\s]+) [NC]
RewriteRule ^ shop/%1/%2/%3/%4? [L,R=302,NE]

RewriteRule ^shop/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ shop.php?c=$1&s=$2&s2=$3&b=$4 [L,QSA,B]
RewriteRule ^shop/([^/]+)/([^/]+)/([^/]+)/?$ shop.php?c=$1&s=$2&s2=$3 [L,QSA,B]
RewriteRule ^shop/([^/]+)/([^/]+)/?$ shop.php?c=$1&s=$2 [L,QSA,B]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php [L]

SSL Apache conf:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>

HTTP Apache conf:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/var/www/example.com">
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
    </Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://www.example.com%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
.htaccess redirect apache2
1个回答
0
投票

您发布的服务器配置文件中没有任何东西会导致重写循环-这里没有重写。

我尝试删除htaccess并使用.php?s=$var,但仍然收到相同的错误

令人费解。子目录中是否还有其他.htaccess文件?没有任何.htaccess文件并且没有发布您的服务器配置,似乎就不可能获得重写循环-因为您根本没有重写!

但是,在某些情况下,最后一个附加了.php扩展名的规则块可能导致重写循环。这需要纠正。您当前有:

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php [L]

这样做的问题是,检查第二个条件以检查<filename>.php是否存在,并不一定要执行相同的文件检查,以使后续的RewriteRule重写。例如。存在/foo/bar的请求/foo.php将导致重写循环。

要解决此问题,您需要将第二个条件改为如下所示:

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f

请参阅下面的ServerFault问题的my answer,该问题将对此进行更详细的说明:

您还应确保已禁用MultiViews(如果尚未禁用),因为您的URL直接映射到文件扩展名小于.php文件扩展名的文件(否则,在mod_rewrite之前,mod_negotiation将重写URL,并且您将丢失URL参数)。在.htaccess文件的顶部包括:

Options -MultiViews
© www.soinside.com 2019 - 2024. All rights reserved.