How to implement to have different robots.txt files for each website hosting on the same Sitecore solution. I want to read dinamically robots.txt from sitecore items.
相关问题
- How to pass “[Sitecore Mobile SDK] Data from the i
- How can I remove duplicated page events in Sitecor
- Spoof an IP address to test GEOIP lookups with Sit
- How to get a Multilist with Search field to not di
- Page.Header.Controls.Add(control) is adding contro
相关文章
- Sitecore set/change default language from 'en&
- Sitecore OMS - achieving a goal on a form submissi
- Get number of components in placeholder, Sitecore
- Sitecore text search in PDF or Word documents
- sending data from one sublayout to another in site
- The model item passed into the dictionary is of ty
- How to implement Solr into Sitecore
- Sitecore enables accessing child node around paren
It seems that if you want to access Sitecore Context, and any items, you need to wait untill this stuff is resolved. The aboce method will always give you a null in the Site definition, as this isnt resolved when the filehandler kicks in.
It seems that to get the Sitecore.Context, you should implement a HttpRequestProcessor in Sitecore, that renderes the robots.txt, example on this website: http://darjimaulik.wordpress.com/2013/03/06/how-to-create-handler-in-sitecore/
We had similar problems especially in the multi site environment, so we used the handlers for implementing robots.txt
Create a new class inheriting from IHTTPHandler and implement the logic within the process method. Write the XML ouput to the context object.
Add the custom handler and trigger.
you need to follow next steps:
1) Create and implement your custom generic (.ashx) handler.
2) In the web.config file add the following line to the section
3) Navigate to the section and add here
4) On home item you will have "Robots" field (memo, or multi line field, not richText field) Your custom generic handler will look like :
You can refer to this blog post for step-by-step explanation on how to do it with a custom HttpRequestProcessor and a custom robots settings template : http://nsgocev.wordpress.com/2014/07/30/handling-sitecore-multi-site-instance-robots-txt/