Request exceeded the limit of 10 internal redirects

前端 未结 7 652
暗喜
暗喜 2020-11-29 07:08

My website has been slowed down a little last couple of days. I\'ve looked into my error log and found lots of these:

[Mon Sep 30 00:09:53 2013] [error] [c         


        
相关标签:
7条回答
  • 2020-11-29 07:09

    Maybe it is a dummie awnser, but I just empty my .htaccess and configure permalinks again. Everything works after that.

    0 讨论(0)
  • 2020-11-29 07:11

    You can also use the END flag, instead of the L flag:

    RewriteRule ^(.*)$ index.php?/$1 [END]
    

    Using the [END] flag terminates not only the current round of rewrite processing (like [L]) but also prevents any subsequent rewrite processing from occurring in per-directory (htaccess) context.

    This does not apply to new requests resulting from external redirects.

    0 讨论(0)
  • 2020-11-29 07:17

    Looking to your htaccess I see that you use it to remove index.php from your url, but you are missing the RewriteBase, you can add it after the RewriteEngine On directly like this:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
    
        #Removes access to the system folder by users.
        #Additionally this will allow you to create a System.php controller,
        #previously this would not have been possible.
        #'system' can be replaced if you have renamed your system folder.
        RewriteCond %{REQUEST_URI} ^system.*
        RewriteRule ^(.*)$ /index.php?/$1 [L]
    
        #When your application folder isn't in the system folder
        #This snippet prevents user access to the application folder
        #Submitted by: Fabdrol
        #Rename 'application' to your applications folder name.
        RewriteCond %{REQUEST_URI} ^application.*
        RewriteRule ^(.*)$ /index.php?/$1 [L]
    
        #Checks to see if the user is attempting to access a valid file,
        #such as an image or css document, if this isn't true it sends the
        #request to index.php
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
        # If we don't have mod_rewrite installed, all 404's
        # can be sent to index.php, and everything works as normal.
        # Submitted by: ElliotHaughin
    
        ErrorDocument 404 /index.php
    </IfModule> 
    AddType image/x-windows-bmp bmp
    

    So, RewriteBase / will be valid if your application/website is not on a subdomain. However, if it is then you might need to add the folder name after the / symbol.

    0 讨论(0)
  • 2020-11-29 07:19

    I had some performance issues in Apache when the loglevel was debug ... Moving back to Error mode speedup the requests

    0 讨论(0)
  • 2020-11-29 07:28

    The last block:

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

    Is most likely re-injecting a changed request URI over and over again which could cause such an internal redirect error. Check the error log with debugging level enabled to trace each redirect step, it makes things much more visible and will tell you exactly which redirect rules are triggering it.

    For a detailed description and how to prevent the re-injection, please see:

    • Mod_Rewrite unexpected behavior L flag

    The solution outlined there actually should do it in your case as well. It's pretty much the same, even the file-names are identical.

    0 讨论(0)
  • 2020-11-29 07:29

    To prevent infinite looping add an extra RewriteCond line on top of your rule like this:

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    

    RewriteCond %{ENV:REDIRECT_STATUS} ^$ prevents looping by checking an internal mod_rewrite variable REDIRECT_STATUS which is set to 200 after first successful internal redirect.

    Reference: Apache mod_rewrite Introduction

    0 讨论(0)
提交回复
热议问题