Block some of dynamic pages from search engines

送分小仙女□ 提交于 2019-12-11 11:44:15

问题


I need to block some of my pages from search engines.How can I do that ? App has been developed by using ASP.net MVC and AngularJS. Thanks in advance.

These are the urls which I want to block from the search engines.

http://localhost:12534/myurl123-event?participant=12957

http://localhost:12534/myurl123-event

Note : The last part of the url is dynamic (i.e. myurl123-event?participant=12957 and myurl123-event).


回答1:


You can use a robots.txt with a disallow setting:

User-agent: *
Disallow: /myurl123-event

If you want to block everything, then you can use

Disallow: /*

or you can put all your dynamic pages inside a route (or use the controller name, if you're routing is straightforward controller/method/id)

Disallow: /dynamic/



回答2:


The Google preferred way is to use canonical links:

<link rel="canonical" href="http://somedomain.com/myurl123-event" />

This tag's function is to tell the search engine what URL should be indexed on these pages containing dynamic querystring params.

See more about them here: Google link

Using these you wont have to worry about accidentally blacklisting part of your site, such as with using robots.txt files and taking a hit on your traffic.



来源:https://stackoverflow.com/questions/31943061/block-some-of-dynamic-pages-from-search-engines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!