7 Replies - 320 Views - Last Post: 14 March 2019 - 02:28 PM

#1 pfar54   User is offline

  • D.I.C Addict

Reputation: 1
  • View blog
  • Posts: 538
  • Joined: 30-April 15

Too many redirects causing site to not load

Posted 14 March 2019 - 07:10 AM

Edit - I figured it out.

However, why when I put
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,NE,L]
under all of my indivudual redirects at the bottom of the file does it break the file?


I was making changed to my htaccess file(forgot to make a copy) and now outside of my index file, my site won't load. I get the error of too many redirects.

Does anyone see what would be causing this error?

Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,NE,L]

RewriteCond %{REQUEST_URI} !^/?(php/uploads)/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]
#<IfModule mod_rewrite.c>
#RewriteEngine on
RewriteRule ^/?(.*).(php|html)$ /$1 [R=301,L]

#</IfModule>

ErrorDocument 404 /404error.php

<ifmodule deflate_module.c>
    DeflateCompressionLevel 1
    DeflateBufferSize 8096
    DeflateMemLevel 8
    DeflateWindowSize 8

    # compress text, html, javascript, css, xml:
	AddOutputFilterByType DEFLATE text/plain
	AddOutputFilterByType DEFLATE text/html
	AddOutputFilterByType DEFLATE text/xml
	AddOutputFilterByType DEFLATE text/css
	AddOutputFilterByType DEFLATE text/javascript
	AddOutputFilterByType DEFLATE application/xml
	AddOutputFilterByType DEFLATE application/xhtml+xml
	AddOutputFilterByType DEFLATE application/rss+xml
	AddOutputFilterByType DEFLATE application/javascript
	AddOutputFilterByType DEFLATE application/x-javascript
	AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
	AddOutputFilterByType DEFLATE application/x-font
	AddOutputFilterByType DEFLATE application/x-font-opentype
	AddOutputFilterByType DEFLATE application/x-font-otf
	AddOutputFilterByType DEFLATE application/x-font-truetype
	AddOutputFilterByType DEFLATE application/x-font-ttf
	AddOutputFilterByType DEFLATE application/x-javascript
	AddOutputFilterByType DEFLATE application/xhtml+xml
	AddOutputFilterByType DEFLATE image/svg+xml
	AddOutputFilterByType DEFLATE image/x-icon
	AddOutputFilterByType DEFLATE font/opentype
	AddOutputFilterByType DEFLATE font/otf
	AddOutputFilterByType DEFLATE font/ttf
</ifmodule>

<IfModule mod_expires.c>
    ExpiresActive On
	##ExpiresDefault A1
	##Header append Cache-Control must-revalidate
    ExpiresByType image/gif A31536000
    ExpiresByType image/jpg A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType image/png A31536000
    ExpiresByType image/bmp A31536000
	ExpiresByType image/ico A31536000
	ExpiresByType image/ico A31536000
	ExpiresByType image/icon A31536000
	ExpiresByType image/x-icon A31536000
    ## ExpiresByType text/css A31536000
	ExpiresByType text/css A31536000
    ExpiresByType text/javascript A31536000
    ExpiresByType application/javascript A31536000
    ExpiresByType application/x-javascript A31536000
	
	# Add a far future Expires header for fonts
	ExpiresByType application/vnd.ms-fontobject A31536000
	ExpiresByType application/x-font-ttf A31536000
	ExpiresByType application/x-font-opentype A31536000
	ExpiresByType application/x-font-woff A31536000
	ExpiresByType image/svg+xml A31536000
	
	<FilesMatch "\.(js|css|xml|gz)$">
		Header append Vary: Accept-Encoding
	</FilesMatch>
  
</IfModule>

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

<IfModule mod_headers.c>

    Header set X-Frame-Options DENY
	Header set X-XSS-Protection "1; mode=block"
</IfModule>

#Survey
Redirect /survey https://kitmb.co1.qualtrics.com/jfe/form/SV_57Jc1QukeDay3XL


Redirect /linear-motion /solution/linear-motion
Redirect /quiz /index
Redirect /answer /index
Redirect /line /index
Redirect /safety-guarding /solution/guarding
Redirect /articles/enclosures /solution/enclosures
Redirect /solution/enclosures/ /solution/enclosures
Redirect solution/guarding/guards-partitions /solution/guarding
Redirect /solution/linear-motion/linear-actuators /solution/linear-motion
Redirect /about-us/t-slot-nuts-fasteners(?:\.html)?$ /components
Redirect /news-events/trade-shows(?:\.html)?$ /events
Redirect /about-us/customer-service(?:\.html)?$ /about
Redirect /about-us/partnerships(?:\.html)?$ /about
Redirect /machining/ /machining
Redirect /guarding/ /solution/guarding
Redirect /material-handling/ /solution/material-handling
Redirect /linear-motion/ /solution/linear-motion
Redirect /workstations/ /solution/workstations
Redirect /structures/ /solution/structures
Redirect /links /index
Redirect /news-events/blog/categories/machine-building.html /index
Redirect /news-events/blog/categories/workbenches.html /solution/workstations
Redirect /news-events/blog/categories/machine-building.html /solution/structures
Redirect /footerTop /index
Redirect /products /catalogs
Redirect /10-linear-motion /solution/linear-motion
Redirect /profile-techical-data /profile-technical-data
Redirect /custom-404=error-page.html /404error
Redirect /news-events/blog.html /learn
Redirect /privacy-policy.html /privacy
Redirect /news-events.html /learn
Redirect /machine-building/workbenches.html /solution/workstations
Redirect /terms-and-conditions.html /terms-conditions
Redirect /about-us/customer-service.html /about
Redirect /about-us/careers.html /careers
Redirect /about-us/partnerships.html /about
Redirect /articles/quote /quote
Redirect /news-events/blog/entry/big-belt-driven-linear-actuators-expand-reach-of-pick-place-system-1(?:\.html)?$ /solution/linear-motion
Redirect /news-events/blog/calendar/2014/10(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2017/4(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2017/1(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/10(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2016/1(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2016/2(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2016/4(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/12(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/7(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/6(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/8(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2016/10(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2016/3(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/3(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2017/3(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2014/11(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/9(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/5(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2016/7(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2015/1(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2017/6(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2017/2(?:\.html)?$ /index
Redirect /news-events/blog/calendar/2016/5(?:\.html)?$ /index
Redirect /news-events/blog/blogger/eric-allen(?:\.html)?$ /index
Redirect /news-events/blog/tags/workbench-system(?:\.html)?$ /solution/workstations
Redirect /news-events/blog/tags/automation-machines(?:\.html)?$ /solution/material-handling
Redirect /news-events/blog/tags/adjustable-height-workbench(?:\.html)?$ /solution/workstations
Redirect /news-events/blog/tags/belt-driven-linear-actuators(?:\.html)?$ /solution/linear-motion
Redirect /news-events/blog/tags/adjustable-height(?:\.html)?$ /solution/workstations
Redirect /news-events/blog/tags/belt-driven-linear-actuators(?:\.html)?$ /solution/linear-motion
Redirect /news-events/blog/tags/extruded-aluminum-profile(?:\.html)?$ /profile
Redirect /news-events/blog/tags/linear-motion(?:\.html)?$ /solution/linear-motion
Redirect /news-events/blog/tags/university(?:\.html)?$ /index
Redirect /news-events/blog/tags/robotics(?:\.html)?$ /index
Redirect /news-events/blog/entry/adjustable-height-workbenches-building-healthier-and-more-productive-environments(?:\.html)?$ /solution/workstations
Redirect /news-events/blog/entry/partnership-with-rockwell-automation-events(?:\.html)?$ /events
Redirect /news-events/blog/entry/trail-by-digging-kent-state-university-competes-at-nasa-robotic-event(?:\.html)?$ /events
Redirect /news-events/blog/entry/mb-kit-systems-dba-item-north-america-celebrates-20-year-anniversary(?:\.html)?$ /learn
Redirect /news-events/blog/entry/mb-kit-systems-inc-to-discontinue-use-of-item-north-america-name(?:\.html)?$ /index
Redirect /images/Subpage_Images/Events/Safety_Invite_2017_West_APR_MBKit.pdf /index
Redirect /about-us/t-slotted-extruded-aluminum(?:\.html)?$ /profile
Redirect /solution/material-handlingmaterial-handling-carts(?:\.html)?$ /solution/material-handling
Redirect /images/material_handling_brochure.pdf /index
Redirect /contact/newsletter-sign-up/12-machine-building(?:\.html)?$ /index
Redirect /solution/material-handlingmodular-conveyors(?:\.html)?$ /solution/material-handling
Redirect /solution/material(?:\.html)?$ /solution/material-handling
Redirect /solution/guarding/custom-enclosures(?:\.html)?$ /solution/enclosures

This post has been edited by pfar54: 14 March 2019 - 07:17 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Too many redirects causing site to not load

#2 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2334
  • View blog
  • Posts: 7,110
  • Joined: 15-January 14

Re: Too many redirects causing site to not load

Posted 14 March 2019 - 12:03 PM

What do you mean "break the file?" What specifically happens? If you're talking about putting that rule after every line starting on line 107, why would you do that? It's going to get to the first on and redirect. There are redirection conditions, you're telling it to always redirect, so it's going to do that the first time it sees that. Also, I don't think the rules on line 13 and 16 will ever hit, because the previous one tells it to stop processing.

Look into moving as much of that as you can into httpd.conf or another file instead of .htaccess. That's a lot of stuff for the server to parse and process for every single request. All of the deflate, expires, gzip, and headers stuff should go in httpd.conf so that it only needs to be read and parsed once instead of for every request.
Was This Post Helpful? 1
  • +
  • -

#3 pfar54   User is offline

  • D.I.C Addict

Reputation: 1
  • View blog
  • Posts: 538
  • Joined: 30-April 15

Re: Too many redirects causing site to not load

Posted 14 March 2019 - 12:15 PM

Thanks. I have never modified a httpd.conf file, so I will look into it and place it in there.

I was told by someone in the SEO community that a lot of my redirects are still rendering http instead of https. This is what he told me.

If you want to see the actual thread, here you are:

http://forums.seocha...her-497495.html

Quote

Redirect rules are actually load order specific. Also it is not readily apparent either.

What that means in your case is this ....

This is a wildcard redirect.
It sends everything as is to mbkit.com without checking for your exceptions !
No other redirect rules will be executed, Period!
Originally Posted by pfar54
Rewrite Rules:
Yes, I have this RewriteRule in my .htaccess file:
RewriteRule ^ https://mbkit.com%{REQUEST_URI} [L,R=301,NE]

Then I have RedirectPermanent for every file that was on the domain redirecting it to the appropriate, most similar page.
Here is how you make everything work properly

Order your redirect rules as follows, copy and paste if you like, this is a working solution to your problem.
Now your exceptions occur first and any you don't redirect now get a wildcard redirect, which is what you want.
They must occur in this order ! Otherwise you get those 404 errors and lose money.

RedirectPermanent /about-us.html https://mbkit.com/about
RedirectPermanent /about-us/t-slotted-aluminum-profiles.html https://mbkit.com/profile
RedirectPermanent /about-us/t-slot-nuts-fasteners.html https://mbkit.com/components
RedirectPermanent /about-us/customer-service.html https://mbkit.com/about
RedirectPermanent /about-us/engineering-services.html https://mbkit.com/about
RedirectPermanent /about-us/careers.html https://mbkit.com/careers
RedirectPermanent /about-us/partnerships.html https://mbkit.com/about
RedirectPermanent /contact.html https://mbkit.com/contact
RedirectPermanent /linear-motion.html https://mbkit.com/so...n/linear-motion
RedirectPermanent /linear-motion/linear-actuators.html https://mbkit.com/so...n/linear-motion
RedirectPermanent /safety-guarding.html https://mbkit.com/solution/guarding
RedirectPermanent /safety-guarding/custom-enclosures.html https://mbkit.com/solution/enclosures
RedirectPermanent /safety-guarding/guards-partitions.html https://mbkit.com/solution/guarding
RedirectPermanent /material-handling.html https://mbkit.com/so...terial-handling
RedirectPermanent /material-handling/modular-conveyors.html https://mbkit.com/so...terial-handling
RedirectPermanent /material-handling/assembly-lines.html https://mbkit.com/so...terial-handling
RedirectPermanent /material-handling/material-handling-carts.html https://mbkit.com/so...terial-handling
RedirectPermanent /machine-building.html https://mbkit.com/solution/structures
RedirectPermanent /machine-building/workbenches.html https://mbkit.com/so...on/workstations
RedirectPermanent /machine-building/stairways-platforms.html https://mbkit.com/solution/structures
RedirectPermanent /news-events/trade-shows.html https://mbkit.com/events
RedirectPermanent /news-events.html https://mbkit.com/events
RedirectPermanent /news-events/blog.html https://mbkit.com/learn
RedirectPermanent /catalog.html https://mbkit.com/catalog/profiles
RedirectPermanent /news-events/blog/entry/safety-doesn-t-pay-or-does-it.html https://mbkit.com/learn
RedirectPermanent /news-events/blog/entry/rise-of-tslot-aluminum-profile.html https://mbkit.com/learn
RedirectPermanent /news-events/blog/entry/aluminum-extrusion-profiles-enable-innovative-hotel-breakfast-bar.html https://mbkit.com/learn
RedirectPermanent /news-events/blog/entry/visit-mb-kit-systems-at-rockwell-automation-events.html https://mbkit.com/events
RedirectPermanent /news-events/blog/entry/big-belt-driven-linear-actuators-expand-reach-of-pick-place-system-1.html https://mbkit.com/so...n/linear-motion
RedirectPermanent /news-events/blog/entry/mb-kit-systems-partners-with-glide-line-conveyors.html https://mbkit.com/
RedirectPermanent /news-events/blog/entry/partnership-with-rockwell-automation-a-win-win-for-mb-kit-systems-customers.html https://mbkit.com/learn
RedirectPermanent /news-events/blog/entry/mb-kit-systems-inc-to-discontinue-use-of-item-north-america-name.html https://mbkit.com/
RedirectPermanent /news-events/blog/entry/mb-kit-systems-dba-item-north-america-celebrates-20-year-anniversary.html https://mbkit.com/
RedirectPermanent /news-events/blog/entry/reshoring-bringing-manufacturing-back-to-the-us.html https://mbkit.com/learn
RedirectPermanent /news-events/blog/entry/new-tools-to-improve-workplace-safety-during-national-safety-month.html https://mbkit.com/learn
RedirectPermanent /news-events/blog/entry/ohio-and-mb-kit-systems-a-vital-partners-in-aerospace-industry.html https://mbkit.com/
RedirectPermanent /news-events/blog/entry/t-slotted-aluminum-profiles-reusable-and-reconfigurable.html https://mbkit.com/profile
RedirectPermanent /news-events/blog/entry/custom-machining-expands-with-additional-cnc-router.html https://mbkit.com/solutions
RedirectPermanent /news-events/blog/entry/aluminum-framing-system-offers-versatility-for-automation-equipment.html https://mbkit.com/so...n/linear-motion


# Now catch all the rest and wildcard them to mbkit.com

RewriteRule ^ https://mbkit.com%{REQUEST_URI} [L,R=301,NE]

# Note : A valuable tip for you, Provided you had no 404 errors before comprehend this.
#
# Keep an eye on your GSC for 404 errors. If you see any it means you
# missed an url and you can readily see it and add it to the rules that run first
# Google can be your friend

Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6794
  • View blog
  • Posts: 31,349
  • Joined: 10-May 07

Re: Too many redirects causing site to not load

Posted 14 March 2019 - 12:22 PM

View Postpfar54, on 14 March 2019 - 02:15 PM, said:

I was told by someone in the SEO community that a lot of my redirects are still rendering http instead of https. This is what he told me.


So I take you've not resolved this topic then? You can clean up a lot of one offs, with a single redirect to attack http -> https.
Was This Post Helpful? 0
  • +
  • -

#5 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2334
  • View blog
  • Posts: 7,110
  • Joined: 15-January 14

Re: Too many redirects causing site to not load

Posted 14 March 2019 - 12:25 PM

If you want to redirect to HTTPS you typically check the port:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Was This Post Helpful? 0
  • +
  • -

#6 pfar54   User is offline

  • D.I.C Addict

Reputation: 1
  • View blog
  • Posts: 538
  • Joined: 30-April 15

Re: Too many redirects causing site to not load

Posted 14 March 2019 - 12:34 PM

(Can't get multi quote to work)
no2pencil - no I haven't resolved it yet. My hosting provider recommended me to not modify the config file with what you said. Plus I am still trying to gain access to SSH to even modify it.


View PostArtificialSoldier, on 14 March 2019 - 12:25 PM, said:

If you want to redirect to HTTPS you typically check the port:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]



I am redirecting to https except for a small fraction of links. The person from the other forum said to put the redirect code under all the other redirects so they are checked first, so it is redirecting to the correct file.
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6794
  • View blog
  • Posts: 31,349
  • Joined: 10-May 07

Re: Too many redirects causing site to not load

Posted 14 March 2019 - 12:37 PM

View Postpfar54, on 14 March 2019 - 02:34 PM, said:

The person from the other forum said to ...

So you're leveraging our help against someone elses. I would pick one direction & go from there. Otherwise, you're playing man in the middle waging two advice givers against one another without really understanding what you're trying to accomplish.

If I'm working on a site with https, I redirect all http traffic to https, regardless. Forget the urls, it's wasted rewrites in an already very complex structure. But that's just me, I'm not your seo guy.
Was This Post Helpful? 0
  • +
  • -

#8 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2334
  • View blog
  • Posts: 7,110
  • Joined: 15-January 14

Re: Too many redirects causing site to not load

Posted 14 March 2019 - 02:28 PM

Quote

If I'm working on a site with https, I redirect all http traffic to https, regardless.

I do the same. Get the protocol correct first then worry about everything else. Then there's no mystery about things still going over HTTP.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1