[FIX] ERR_TOO_MANY_REDIRECTS on WordPress (2021)
文章推薦指數: 80 %
The ERR_TOO_MANY_REDIRECTS error is often triggered by reverse-proxy services such as Cloudflare, or other reverse proxy services. This is what ...
HomeWordPressTipsandTricksTutorialsThemesPluginsWooCommerceJoomlaTipsandTricksModulesTutorialsWebDesignWebHostingGuidesDetailsShahzadSaeedTutorialsDetailsLastUpdated:26July2021WeseealotofdifferentWordPresserrorsatCollectiveRay,andoneofthemisERR_TOO_MANY_REDIRECTS(alsoknownasaredirectloop).ThistypicallyhappensasaresultofanewupdatetoyourWordPressplatform,amisconfigurationofredirectsonyourserver,orinappropriateconfigurationsforthird-partyproviders.Butdon'tworry,thismistakeisprettysimpletofix.Checkoutthetipsbelowforhowtoresolvethiserrorandgetthesiteupandrunningagain.Contents[Show]Whatisthe err_too_many_redirects error?ERR_TOO_MANY_REDIRECTSChromeMicrosoftEdgeBrowserFirefoxSafariHowtoFixERR_TOO_MANY_REDIRECTS 1.DeleteBrowserCookiesforThatSpecificSite2.ClearServer,Proxy,andBrowserCacheClearWordPressSiteCacheClearServerCacheClearCDNorProxyCacheClearBrowserCacheDeterminetheTypeofTheRedirectLoopCheckYourHTTPSConfiguration1.DonotforceHTTPSifyouhaven'tinstalledanSSLcertificate.2.Updateanyhard-codedlinks,insteadofusinganSSLplugin3.CheckanyHTTPtoHTTPSRedirectsontheServer4.CheckforTooManyHTTPSRedirectsCheckThird-PartyServicesCheckYourWordPressSiteConfigurationWordPressMultisiteDisableWordPressPluginsTemporarilyCheckanyexistingServerRedirects.htaccessfileinApacheNginxConfigurationReverseProxiesThatAreMisconfiguredWrappingUpWhatisthe err_too_many_redirects error?ThereasonwhyERR_TOO_MANY_REDIRECTSistriggerediseasilyreflectedintheerroritself.Something(amisconfiguration)istriggeringadisproportionateamountofredirects(toomanyredirects),causingyourwebsitetogointoacontinuousredirectionloop.Essentially,theserveristrapped(forexample,URL1pointstoURL2andURL2pointsbacktoURL1,orthedomainhasforwardedyoutoomanytimes).Thistypesoferroristypicallyanincorrectsystemsetup,soit'shardfortheseerrorstogetresolvedbythemselves.Thisiswhywehaveastep-by-stepguideonwhatstepsyouneedtotaketoresolvethisissue.Dependingonthebrowseryou'reusing,thereareafewdifferentvariantsofthiswarning/error.ERR_TOO_MANY_REDIRECTSChromeThiserrorwillbeshowninGoogleChromeasERR_TOO_MANY_REDIRECTS(asseenbelow)orThiswebpagehasaredirectloopissue.Thispageisn’tworking.example.comredirectedyoutoomanytimes.Tryclearingyoucookies.ERR_TOO_MANY_REDIRECTSOtherGoogleChromeproblemsthatcanbefixedeasilyincludetheerr_cache_misswarning.MicrosoftEdgeBrowserIntheMicrosoftEdgebrowser,itwillsimplyshowas Thispageisn’tworkingrightnow (asyoucanseebelow).example.comredirectedyoutoomanytimes.FirefoxIntheMozillaFirefoxbrowser,thiswouldbeshownasThepageisn'tredirectingproperly(asseeninthescreenshotbelow).Anerroroccuredduringaconnectiontoexample.com.Thisproblemcansometimesbecausedbydisablingorrefusingtoacceptcookies.SafariIntheSafaribrowser,theerrorwillshowas SafariCan’tOpenthePage (checkoutthescreenshot).Toomanyredirectsoccurredtryingtoopen“example.com.”Thismightoccurifyouopenapagethatisredirectedtoopenanotherpagewhichisthenredirectedtoopentheoriginalpage. Herearefewtipsandproblemstosearchfortohelpresolvetheerror(sortedbythemostcommonexplanationswesee):DeleteorclearcookiesonthatspecificsiteClearallcachesontheWordPresssite,(plugin,server,proxy,andbrowsercache)DeterminenatureofredirectloopCheckthatyouhavethecorrectHTTPSsettingsCheckanythird-partyservicesCheckyourWordPresssitesettingsTemporarilydisableWordPresspluginsuntilyouresolvetheproblemCheckforanyredirectsonyourserverHowtoFixERR_TOO_MANY_REDIRECTS 1.DeleteBrowserCookiesforThatSpecificSiteAswesawinthescreenshotsabove,bothGoogleandMozillaadviserightbelowtheerrorto"tryclearingyourcookies."Cookiescangetcorruptedandhaveerroneousdata,resultingintheERRTOOMANYREDIRECTSerror.Thisisafixyoushouldtryeventhoughyou'regettingtheerroronaplatformorwebsitethatyoudon'town.Sincecookiesmaintainyour"loggedin"statusandothersettingsonwebsite,wesuggestsimplyremovingthecookie(s)onthesitethatiscausingtheissue.Thisway,youwon'tcauseanyproblemswithanyoftheotherwebsitesessionsorregularlyvisitedwebsites.TodeleteacookiefromaparticularwebsiteinGoogleChrome,followthestepsbelow.Clickthethreelittledotsintheupperright-handcornerofGoogleChrome.Thenchoose"Settings."Scrolldownandchoose"Advanced."Clickon"Contentsettings."Choose“Cookies.”Next,choose“Seeallcookiesandsitedata."Lookforthesite(domain)thatistriggeringtheERR_TOO_MANY_REDIRECTSwarning.Thecookie(s)currentlysavedonyourcomputerforthatdomainwillthenberemoved.Thenreturntothewebsiteandrefreshthepage.Iftheproblemwascausedbybrowsercookies,theerrorwillnotbegoneandthepagewillloadcorrectly.2.ClearServer,Proxy,andBrowserCacheSince redirect loopscanbetriggeredby caching responses, it's always a good idea to try clearing the cache on your WordPress account, the server, third-party proxy servers, and even your browser if required.Dependingonthetypeofredirectloop,youmightstillbeabletoacessyourWordPressadmindashboard.Inthiscase,youcanconvenientlyflushorclearthecachefromyourcachingplugin'ssettings. Here'sisabriefguideonhowtoclearthecachesonthevariouspiecesofinstrastructurethatcouldhavecaching.Youmightneedtocheckwhatpluginsyourwebsiteisrunning,orwhetherthereisadifferentcachingplatformthatwehaven'tmentionedbelow. Makesurethatyouclear,flushorpurgethecachesoneachcachingcomponent.ClearWordPressSiteCacheIfyouarecachingyoursiteusingaWordPresscachingpluginsuchasW3C,SuperCacherorevenWPRocket,flushingthecacheonthesepluginsisusuallyverystraightforwardandissomethingwhichyouprobablyhavedoneseveraltimes. Simplyfollowyourusualproceduretopurgetherelevantcachingplugin.ClearServerCacheSomemanangedWordPresshostingservicessuchasKinsta,WPEngine,NexcessorSiteGroundhavetheirownserver-levelcaching.Allofthesehavetheirownprocedurestofollowtoflushthecaches.Thisshouldbeeasilyaccessibleviayourhostingdashboard.ClearCDNorProxyCacheIfyouuseathird-partyreverse-proxyservice,suchasCloudflareorSucuri,clearingthecacheontheirendmayalsobehelpful.AlthoughnotallCDN'sworkasproxies,ifyouareonaCDN,youmightwanttoflushorpurgethecacheheretoo. SignintoCloudflare'sdashboard,navigateto"Caching,"andthenhit"PurgeEverything."LogintoSucuri'sdashboard,navigateto"Performance,"andthenpress"ClearCache." ClearBrowserCacheIfyouneedtoseeifit'syourlocalbrowsercachethatiscausingtheproblem,youcanopenyourbrowserinincognitomodewithoutdeletingyourcache.Alternatively,useanotherbrowsertoseeiftheERR_TOO_MANY_REDIRECTSerrorpersists.Ifyoudeterminethatitisduetothebrowsercache,youneedtoclearit.Hereareguidelinesfordoingsoindifferentbrowsers:Clearyourwebbrowser'scache,cookies,andhistoryDeterminetheTypeofTheRedirectLoopIfclearingthecachedidn'twork,you'llwanttotryandfigureoutwhat'scausingtheredirectloop.HTTPStatus.io-afreeonlineredirectcheckertoolwillassistwithfurtheranalysisonwhatisgoingonatthebackend.ThismayalsobeaccomplishedwithcURL.Onthesitebelow,forexample,thereisa301redirectloopbacktoitself,resultinginalongchainofdefectiveredirects.Youshouldfollowalloftheredirectsandseeifitisloopingbacktoitself,orifitisanHTTPtoHTTPSloop,whichwewilladdressbelow.301Redirecthttps://example.com301Redirecthttps://example.com301Redirecthttps://example.com301Redirecthttps://example.comTheRedirectPathChromeextensionisalsoveryhelpful,sinceitoffersinformationonanyoftheredirectsthatoccuronyourweb(specificURLorpage).CheckYourHTTPSConfigurationAnotherthingtodouble-checkistheHTTPSsetup.We'veseenERR_TOO_MANY_REDIRECTSariseoftenwheresomeonehasjustmovedtheirWordPressplatformtoHTTPSandthendidn'tfinishthesetupcorrectly.1.DonotforceHTTPSifyouhaven'tinstalledanSSLcertificate.Thisisbyfarthemostpopularexplanationweexperienceveryoften.IfyouforceyourWordPresssitetoloadoverHTTPSwithoutfirstsettingupanSSLcertificate,yoursitewillautomaticallycreatearedirectloop.Tofixthisproblem,simplyinstallanSSLcertificateonyourWordPresssite'saccount.Youcanuseeitheracommerciallyboughtcertificate,orelseuseLet'sEncryptifthisissupportedbyyourhostingsetup.It'salsoasmartideatorunanSSLscan (fromQualysSSLLabs)onyoursite.SSL/TLScertificatesrequiretheinstallationofnotonlytheprimarycertificate,butalsowhatareknownasintermediatecertificates(chain).Thesemustbecorrectlyinstalled,otherwiseyoursetupwillnotbecorrectandmaycreateallsortsofproblems.SimplygototheSSLchecker,linkedabove,enteryourdomainintheHostnamefield,andpress"Submit."Youcanchoosetonotmaketheresultsofthescanpublic.Notethatthescanningofyoursite'sSSL/TLSconfigurationonyourwebservercantakeaminuteortwo.2.Updateanyhard-codedlinks,insteadofusinganSSLpluginTherearesomefreeSSLWordPresspluginsavailable,suchastheReallySimpleSSLplugin,thatwillhelpyouinautomaticallyredirectingtoHTTPS.However,wedonotsuggestthisapproachasalong-termsolutionbecausethird-partypluginscanintroducenewbugsorcauseotherperformanceissues.Whileitmaybeaneasytemporaryworkaround,youshouldstillendevourtoconvertyourhard-codedHTTP://linkstoHTTPS://.YoucanachievethiswithatoolsuchasBetterSearchReplaceinWordPressorgetintouchwithyourhostingsupportteamtogetthishandledforyou.3.CheckanyHTTPtoHTTPSRedirectsontheServerAnotherreasonfortheerrorcouldbethattheHTTPSredirectrulesonyourserveraremisconfigured.IfyourwebserverisrunningNginx,youcaneasilyredirectallHTTPtraffictoHTTPSbyapplyingthefollowingcodetoyourNginxconfigfile.ThisisthepreferredapproachforredirectingWordPressonNginx.server{listen80;server_nameexample.comwww.example.com;return301https://example.com$request_uri;}IfyouhaveanApachewebserver,youcanalsoeasilyredirectallHTTPtraffictoHTTPSbyapplyingthefollowingcodetoyour.htaccessfile.ThisisthepreferredapproachforredirectingWordPressusingtheApacheserver.RewriteEngineOn
RewriteCond%{HTTPS}off
RewriteRule^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]4.CheckforTooManyHTTPSRedirectsAnotherpossbilityisthatyouhavetoomanyHTTPSredirects.YoucanusetheRedirectmapperfeature,toquicklyidenitfyhowmanyredirectsyoursitehas.Belowisanexampleofaredirectthatwasn'tsetupright,andiseasytofindusingtheredirectmapper.ThereareduplicateHTTPSredirectsonboththewwwandnon-wwweditions,asyoucansee. CheckThird-PartyServicesTheERR_TOO_MANY_REDIRECTSerrorisoftentriggeredbyreverse-proxyservicessuchasCloudflare,orotherreverseproxyservices.ThisiswhatmighthappenwhentheirFlexibleSSLoptionisenabledandyoualreadyhaveanSSLcertificateinstalledwithyourWordPresshost.Whydoesthishappen?WhenyouchooseFlexibleSLL,allrequeststoyourhostingserveraresentviaHTTP.SinceyourhostserveralreadyhasaredirectfromHTTPtoHTTPSinplace,aredirectloophappens.Toovercomethis,changetheCloudflareCryptosettingsfromFlexibletoFullorFull(strict).YoushouldusetheirAlwaysUseHTTPSpageruletoautomaticallyredirectalluserstoHTTPSwithoutcausingaloop.AnotherissuetobeawareofwithCloudflareistheirforwardingURLredirectionrules.Besurenottobuildaredirectinwhichthedomainreferstoitselfasadestination.Thiswillresultinaninfiniteredirectloop,andtheURLsaffectedwouldbeunabletoresolvecorrectly.IfyouprefertouseonlyCloudflare'sDNSandnottheirproxy/WAFservice,makesureyourDNSrecordsaresetto"DNSOnly."Thecloudiconwouldlook"blue"ratherthan"orange."ThiscanbeseenintheCloudflarecontrolpanelunderthe“DNS”tab.Ifyou'reusingStackPath,makesurethe"OriginPullProtocol"optionissettoHTTPSonly.CheckYourWordPressSiteConfigurationAnotherthingtolookatistheWordPresssitesettings.You'llwanttodouble-checkifthetwofieldsaresetproperlyandaren'treferringtothesamedomain,oraremismatched.Anothertypicalproblemisfailingtousetherightprefixtomatchtherestofthedomain,whetherwwwornon-www.Whenpeoplemigratehostsorshiftdomains,thesesettingsmaybechangedwithoutyournoticing.WordPressAddress(URL):TheURLtoreachyoursite.SiteURL(UniformResourceLocator):ThelocationofyourWordPresscorefiles.Theseshouldmatch,unlessWordPressisbeingusedititsowndirectory.Ifthesesettingsarenotsetcorrectly,youwillbeunabletoaccessyourWordPressdashboard.Soyoucancircumventtheabovesettingsbychangingthevaluesinyourwp-config.phpfile.Thewp-config.phpfileisnormallyfoundattherootofyourWordPresssiteandcanbeaccessedviaFTP,SSH,orWP-CLI.Simplyaddthefollowingcodetothetopofthefiletohard-codeWP_HOMEandWP_SITEURL,modifyingthevaluestoreflectyourdomain.define('WP_HOME','https://example.com');define('WP_SITEURL','https://example.com'); Aftermanuallyconfiguringthetwovalues,youcanvisityoursiteandseewhetheritresolvestheredirectloop.WordPressMultisiteWhenmovingdomainsonamultisite,makesuretosearchthewp_blogstableaswell.Ifyouperformanincorrectsearchandreplace,thiscanresultinaninfiniteredirectloop.Thisisduetothenetworksitenotmatchingthesubsites.wp_#_options:Foreachsubsite,aseriesoftableswillbegeneratedthatcorrespondtotheblogidinthewpblogstable.Updatethe“SITEURL”and“HOME”settingsinthewp_#_optionstable,where#referstotheblogid.DisableWordPressPluginsTemporarilyWhenitcomestoWordPress,brieflyremovingallWordPresspluginscanbeafastwaytoidentifyissues.Redirects,forexample,maybeimplementedusingpluginssuchasRedirectionorYoastSEOpremium.Oftenanychangesinconfigurationorotheralterationstothesepluginswillclashwithredirectsthatarealreadyinplaceonyourserver,resultinginaredirectloop.Rememberthatmerelydisablingapluginwillnotresultindataloss,sothisisafairlyrisk-freefix.Ifyoucan'treachtheWordPressadmin,you'llneedtoconnecttoyourserverthroughSFTPandrenameyourpluginsfoldertosomethinglikepluginsold.Thendouble-checkyourwebsitetoseewhethertheredirectloopisgone.Ifitworks,you'llneedtoverifyeachpluginone-by-oneandseewhetheritistheonecausingtheproblem.Renameyourpluginfolderbackto"plugins,"thenrenameeachpluginfolderinsideitonebyoneuntilyoulocatetheonewhichcausesaproblem.Youmightwanttotestthisonastagingsitefirst. CheckanyexistingServerRedirectsApartfromHTTPtoHTTPSredirectsonyourserver,it'sagoodideatodouble-checkwhethertherearen'tanyotherredirectssetupincorrectly.Foreg,asinglebad301redirectbacktoitselfmightbringthesitedown.Thisareusuallycontainedinyourserver'sconfigurationfiles..htaccessfileinApacheIfyou'reusinganApache-poweredWordPresshost,it'slikelythatyour.htaccessfileincludesanincorrectconfig.Tomakeanewonefromscratch,followthestepsbelow.ConnecttoyoursiteusingFTPorSSHandrenameyour.htaccessfileto.htaccess-old.Thismeansthatyoustillhaveabackupoftheoldconfigureation.Normally,youshouldeasilysaaveyourpermalinksinWordPresstorestorethisfile.However,ifyou'reseeinganERR_TOO_MANY_REDIRECTSbug,youwon'tbeabletologintoyourWordPressadmin,sothisisn'tanavailableoption.Asaresult,youshouldcreateanew.htaccessfilewiththefollowingcode.Thefollowingexampleusesdefaultsettings.#BEGINWordPress
延伸文章資訊
- 1How to Fix ERR_TOO_MANY_REDIRECTS in WordPress
The ERR_TOO_MANY_REDIRECTS error happens when a browser can't connect to the correct server of yo...
- 2Easy Fixes for “ERR_TOO_MANY_REDIRECTS” Error on ...
How to Fix “ERR_TOO_MANY_REDIRECTS” Error · Clear Your Browser's Cookies · WordPress URL Settings...
- 3How to Fix The ERR_TOO_MANY_REDIRECTS Error - Kinsta
Clear WordPress site, server, proxy, and browser cache
- 4[FIX] ERR_TOO_MANY_REDIRECTS on WordPress (2021)
The ERR_TOO_MANY_REDIRECTS error is often triggered by reverse-proxy services such as Cloudflare,...
- 5How to fix ERR_TOO_MANY_REDIRECTS in WordPress
What is ERR_TOO_MANY_REDIRECTS or redirection loop · How to fix ERR_TOO_MANY_REDIRECTS. The cooki...