gpt4 book ai didi

angularjs - 用于 SEO 配置的 .htaccess 重定向

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:43:44 26 4
gpt4 key购买 nike

我有一个基于 angularJs 的组合,谷歌爬虫为类似平台提供了一个 URI 工具。将 #! 替换为 ?_escaped_fragment_=,您可以使用服务器重定向更改目录以提供静态文件。

我不使用 #! 所以 ?_escaped_fragment_= 将被插入到最后。我喜欢做的是制作这个图案:

www.mywebsite.com/?_escaped_fragment_=
www.mywebsite.com/page/?_escaped_fragment_=
www.mywebsite.com/page/5?_escaped_fragment_=

重定向到

www.mywebsite.com/snapshot
www.mywebsite.com/snapshot/page/
www.mywebsite.com/snapshot/page/5

这是我使用的 .htaccess 文件:

RewriteEngine On  
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$
RewriteRule ^$ /snapshot/
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html

问题是它只适用于基本 URL (index.html)。有什么我想念的吗?谢谢。

最佳答案

你必须像这样使用转义片段:

http://yourangularwebsite.com/?_escaped_fragment_=/page/5

然后在您的 .htaccess 中重定向它:

RewriteCond %{QUERY_STRING} _escaped_fragment_=/([^&]*)
RewriteRule ^$ /snapshot/%1 [R,L]

这会将您重定向到 http://yourangularwebsite.com/snapshot/page/5?_escaped_fragment_=/page/5

关于angularjs - 用于 SEO 配置的 .htaccess 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35819462/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com