0
我使用Angular JS模板引擎創建了簡單的應用程序,但是當我在社交媒體中共享網址時,內容未被解析,因此顯示「{{}}」,所以我使用htaccess。每當臉書請求我http://website.com/posts/value-1我希望它重定向到靜態php文件http://website.com/static.php?id= $ 1,但它不是重定向使用下面的htaccess文件,任何解決方案?無法重定向Facebook的Facebook HTTP用戶代理
RewriteEngine on
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule^- [L]
# If the requested resource doesn't exist, use index.html
RewriteRule^/pages/index.html
Redirect /index.html http://website.com/home/
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9](+http://www.facebook.com/externalhit_uatext.php)|Twitterbot|Pinterest|facebot/[0-9]|Google.*snippet)
RewriteRule ^posts/(.*)$ http://www.website.com/static.php?id=$1 [NC,L]
你看了'逃脫fragment'方法? http://stackoverflow.com/questions/26003186/facebook-scrapper-and-angular-app-with-html5mode-hashbang-urls。 – Roemer
@Roemer謝謝你的幫助 –