Last active
April 10, 2018 17:38
-
-
Save mreigen/4dc8effec8186315c3aac4ce6da46c9a to your computer and use it in GitHub Desktop.
Goal: 1) To remove the # hash from the url. 2) Shareable on Facebook, twitter... with dynamic meta tags
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
//AngularJS app | |
.config( function myAppConfig ($locationProvider) { | |
$locationProvider.html5Mode(true); | |
... | |
} |
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
<!-- AngularJS app --> | |
<head> | |
<base href="/"> | |
</head> |
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
# NGINX location block | |
# this will PROXY-ly map (not 301 redirect) all the crawling requests from facebook, twitter bots... to the server that hosts | |
# the template for sharing. On the template, we will diplay only the meta tags in the head (See the template file in this same gist) | |
# This block goes first | |
location /kids { | |
if ($http_user_agent ~* "facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet") { | |
rewrite ^/kids/(.*) /kids/$1/share_for_proxy_passing break; | |
proxy_pass http://the-server-that-hosts-the-template-share-for-proxy-passing.com; | |
} | |
rewrite ^/kids/(.*)$ /#/kids/$1 last; | |
} | |
# Then this | |
location / { | |
try_files $uri /index.html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment