Free Facebook Crawler from .htaccess redirects

Recently, we made all pages be HTTPS via .htaccess:

RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

The problem is that I get the “Circular redirect path detected” from the Facebook debugger because the source URL is https but the og: http url (so we don’t lose all of our old ones) and then it gets a 302 loop returned to https.

How can I make Facebook an exception to this .htaccess rule?

+6
source share
1 answer

This question addresses a user agent that will look like external facebook images. You just need to add a condition to check:

 RewriteEngine on RewriteCond %{HTTPS} off RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9] RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
+10
source

Source: https://habr.com/ru/post/955200/


All Articles