我正在aws上使用php 7来运行我的php应用程序,它的流量不错。但是,在一天结束时,我检查了我的Apache日志中是否存在错误/活动。我每天发现10到15行有相同错误的常见情况
AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
但是我无法收到此错误,为什么会发生,我以某种方式知道它是由于重定向/.htaccess中的某些规则而发生的。我无法找到逻辑故障所在的位置,因为它不会在本地主机上提供任何错误,也不会在运行任何脚本时提供错误。
下面是我的.htaccess代码
<IfModule mod_rewrite.c>
RewriteEngine On
# for subdomain like test.example.com to redirect to https://test.example.com
#RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
#RewriteCond %{HTTPS} off
#RewriteCond %{HTTP_HOST} ^([\.\w\-]*)\.(com|in)$ [NC]
#RewriteRule ^ https://%1.%2%{REQUEST_URI} [R=301,L,NE]
# We are setting here the default file to load while the URL is called followed by fallback files
DirectoryIndex index.php
# Redirect all requests except only POST
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.(?:php?)[\s?/] [NC]
RewriteRule ^ /%1%2 [R=302,L,NE]
# Adds a trailing directory if rewritten URI is a direcory
RewriteCond %{DOCUMENT_ROOT}/app/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L]
# Over here we have set the default root directory now request will be directly made from this directory
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteCond %{REQUEST_URI} !/app/ [NC]
RewriteRule (.*) /app/$1 [L]
# over here we're removing .php extensions
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
# code to make pretty URLS | we're using this code to achieve /category/slug
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.+)/([\w-]+)/([\d]+)$ app/post.php?&category=$2&page=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.+)/([\w-]+)/([\w-]+)$ app/post.php?&category=$2&slug=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.+)/([\d]+)$ app/index.php?page=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.+)/([\w-]+)$ app/post.php?category=$2 [L]
# we have set here custom error files to handle server errors
ErrorDocument 404 /app/error_pages/404.php
ErrorDocument 403 /app/error_pages/403.php
ErrorDocument 500 /app/error_pages/500.php
# We are setting here default charset & language headers setting for our website
AddDefaultCharset UTF-8
DefaultLanguage en-US
</IfModule>
# --------------------------------------------------- Caching Rules Section ---------------------------------------------------
<IfModule mod_headers.c>
<filesMatch "\.(woff|otf|eot|opentype|ttf|woff2)$">
#for a year
Header set Cache-Control "max-age=31556952, public, must-revalidate"
</filesMatch>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
#for a month
Header set Cache-Control "max-age=2629746, public, must-revalidate"
</filesMatch>
<filesMatch "\.(css|scss|min|min.css)$">
#for a week
Header set Cache-Control "max-age=604800, public, must-revalidate"
</filesMatch>
<filesMatch "\.(js|min|min.js)$">
#for 3 days
Header set Cache-Control "max-age=259200, private, must-revalidate"
</filesMatch>
#<filesMatch "\.(x?html?|xml)$">
# Header set Cache-Control "private, must-revalidate"
#</filesMatch>
</IfModule>
# --------------------------------------------------- Caching Rules Section ---------------------------------------------------
Allow from all
# Disable directory browsing
Options All -Indexes
强制将LimitInternalRecursion 20添加到httpd.conf或.htaccess中