AngularJS SEO htaccess的:重定向根域为快照

编程入门 行业动态 更新时间:2024-10-20 00:21:38
本文介绍了AngularJS SEO htaccess的:重定向根域为快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我用角与HTML5模式

$ routeProvider.otherwise({redirectTo:/指数'});  $ locationProvider.html5Mode(真).hash preFIX(!);

和我有htaccess的处理谷歌索引

#重写与谷歌附加字符串到快照的英文版什么  的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^ touchtyping.guru [NC]  重写规则^快照%{REQUEST_URI} -en.html [L]  #改写一切以index.html来让HTML5状态的链接  重写规则^的index.html [QSA,L]

这重定向到适当的快照所有子页,例如像:

touchtyping.guru/learn-touch-typing?_escaped_fragment_=  touchtyping.guru/index?_escaped_fragment_=

但它并不像下面的根域,渲染,而不是重定向到它/索引页,作品的快照:

touchtyping.guru/?_escaped_fragment_=

快照存在,我尽力codeD指数en.html那里,但没有成功。好像htaccess的不赶查询字符串在这种情​​况下,加载角路由。我该如何解决呢?

更新--------------------------------------

全htaccess文件:

RewriteEngine叙述上  #不要重写文件或目录  的RewriteCond%{} REQUEST_FILENAME -f [OR]  的RewriteCond%{} REQUEST_FILENAME -d  重写规则^ - [L]  #重定向HTTP:// WWW。只是HTTP://  的RewriteCond%{HTTP_HOST} ^ WWW \。(。*)$ [NC]  重写规则^ $ HTTP(*)://%1 / $ 1 [R = 301,L]  的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^ touchtyping.guru [NC]  重写规则^快照%{REQUEST_URI} -en.html [L]  的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^(ES | PL | EN).touchtyping.guru [NC]  重写规则^快照%{REQUEST_URI} - %1.HTML [L]  #改写一切以index.html来让HTML5状态的链接  重写规则^的index.html [QSA,L]

解决方案

你有没有尝试添加一个特定的规则是什么?

的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^ touchtyping.guru [NC]  重写规则^ $快照/指数en.html [L]

编辑:

尝试重新安排您的规则了一下:

RewriteEngine叙述上  #重定向HTTP:// WWW。只是HTTP://  的RewriteCond%{HTTP_HOST} ^ WWW \。(。*)$ [NC]  重写规则^ $ HTTP(*)://%1 / $ 1 [R = 301,L]  的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^ touchtyping.guru [NC]  重写规则^(指数\ html的)?$快照/指数en.html [L]  的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^(ES | PL | EN).touchtyping.guru [NC]  重写规则^(指数\ html的)?$快照/转位%1.HTML [L]  #不要重写文件或目录  的RewriteCond%{} REQUEST_FILENAME -f [OR]  的RewriteCond%{} REQUEST_FILENAME -d  重写规则^ - [L]  的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^ touchtyping.guru [NC]  重写规则^快照%{REQUEST_URI} -en.html [L]  的RewriteCond%{QUERY_STRING} ^ _escaped_fragment_ =  的RewriteCond%{HTTP_HOST} ^(ES | PL | EN).touchtyping.guru [NC]  重写规则^快照%{REQUEST_URI} - %1.HTML [L]  #改写一切以index.html来让HTML5状态的链接  重写规则^的index.html [QSA,L]

I use angular with html5 mode

$routeProvider.otherwise({redirectTo : '/index' }); $locationProvider.html5Mode(true).hashPrefix('!');

and for that I have htaccess to handle google indexing

# Rewrite anything with google appended string to english version of the snapshot RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^touchtyping.guru [NC] RewriteRule ^ snapshots%{REQUEST_URI}-en.html [L] # Rewrite everything else to index.html to allow html5 state links RewriteRule ^ index.html [QSA,L]

This redirects to appropriate snapshot for all the subpages, like eg:

touchtyping.guru/learn-touch-typing?_escaped_fragment_= touchtyping.guru/index?_escaped_fragment_=

but it doesn't work for the root domain like below, rendering the /index page, instead of redirecting to it's snapshot:

touchtyping.guru/?_escaped_fragment_=

The snapshot exists, I tried hardcoded index-en.html there, but no success. Seems like htaccess doesn't catch the query string in this case, loading angular routing. How can I fix that?

UPDATE--------------------------------------

The whole htaccess file:

RewriteEngine on # Don't rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] # Redirect www. to just RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ %1/$1 [R=301,L] RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^touchtyping.guru [NC] RewriteRule ^ snapshots%{REQUEST_URI}-en.html [L] RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^(es|pl|en).touchtyping.guru [NC] RewriteRule ^ snapshots%{REQUEST_URI}-%1.html [L] # Rewrite everything else to index.html to allow html5 state links RewriteRule ^ index.html [QSA,L]

解决方案

Have you tried adding a specific rule for that?

RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^touchtyping.guru [NC] RewriteRule ^$ snapshots/index-en.html [L]

EDIT:

Try re-arranging your rules a bit:

RewriteEngine on # Redirect www. to just RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ %1/$1 [R=301,L] RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^touchtyping.guru [NC] RewriteRule ^(index\.html)?$ snapshots/index-en.html [L] RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^(es|pl|en).touchtyping.guru [NC] RewriteRule ^(index\.html)?$ snapshots/index-%1.html [L] # Don't rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^touchtyping.guru [NC] RewriteRule ^ snapshots%{REQUEST_URI}-en.html [L] RewriteCond %{QUERY_STRING} ^_escaped_fragment_= RewriteCond %{HTTP_HOST} ^(es|pl|en).touchtyping.guru [NC] RewriteRule ^ snapshots%{REQUEST_URI}-%1.html [L] # Rewrite everything else to index.html to allow html5 state links RewriteRule ^ index.html [QSA,L]

更多推荐

AngularJS SEO htaccess的:重定向根域为快照

本文发布于:2023-11-01 18:12:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550046.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:快照   重定向   AngularJS   SEO   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!