Created
February 28, 2013 08:09
-
-
Save mechiland/5055089 to your computer and use it in GitHub Desktop.
nginx allow crawler to visit website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $http_user_agent $is_bot { | |
default 0; | |
~*(crawl|Googlebot|Slurp|spider|bingbot|yodaobot|youdaobot)$ 1; | |
} | |
set $should_redirect 1; | |
if ($is_bot) { | |
set $should_redirect 0; | |
} | |
if ($ssl_protocol != "") { | |
set $should_redirect 0; | |
} | |
if ($should_redirect = 1) { | |
rewrite ^ https://$host$request_uri? permanent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment