我使用Angular JS模板引擎创建了简单的应用程序但是当我在社交媒体内容中共享url时,它没有被解析它显示“{{}}”所以我使用htaccess工作。每当facebook请求我http://website.com/posts/value-1时,我希望它重定向到http://website.com/static.php?id= $ 1的静态php文件,但它不是使用下面的htaccess文件重定向,Any Solutions?
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]
答案 0 :(得分:0)
我自己解决了下面的工作.htaccess代码
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]