【问题标题】:.htaccess redirection for SEO configuration.htaccess 用于 SEO 配置的重定向
【发布时间】:2016-06-19 13:41:04
【问题描述】:

我有一个基于 angularJs 的产品组合,Google 爬虫为类似平台提供了一个 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)。 有什么我想念的吗? 谢谢。

【问题讨论】:

    标签: angularjs .htaccess seo


    【解决方案1】:

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

    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

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 2018-04-28
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-07
      • 1970-01-01
      相关资源
      最近更新 更多