Sorry to ask but why would you do like that?
These files should be in the root of the site, that is the place all robots are looking for them.
Yeah, I know. It could be any other file and robots was placed here just for test, and of course this file placed at root. But it's doesn't matter now.
Hello Aliaksei, you may want to consider using EPiRobots to render your robots.txt file as this means its editable inside EPiServer:
http://www.markeverard.com/2013/11/01/a-robots-txt-handler-for-episerver-7/
I read this. But I user Episerver 8 and this module has a compatibility problems. I have no resolve for this.
So how can i write file to server filesystem & after have posibility to load it?
If you are using MVC you can use routing. It might be possible with webforms also
Read more here:
http://stackoverflow.com/questions/21934150/static-file-routes-in-asp-net-mvc
This link might be useful. It gives you good examples on how to write/read files
http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Content/Assets-and-media/Working-with-media/
Why not server the robots.txt as an ordinary property on startpage via an controller? Easy to create that if you like. Just an action returning a robots.txt instead of a view. You also need to register a route for the robots.txt in a initialization module of episerver.
But it is like 10 lines of code :) In the below sample I have used a settingspage but you could have the property stored in the startpage instead.
Something like this: http://www.edandersen.com/2013/02/17/adding-a-dynamic-robots-txt-file-to-an-asp-net-mvc-site/
//Maps route for robots.txt RouteTable.Routes.MapRoute("RobotsTxtRoute", "robots.txt", new { controller = "RobotsTxt", action = "Index" });
/// <summary> /// Controller for serving robots.txt and content from startpage property. /// </summary> public class RobotsTxtController : Controller { private Injected<IContentLoader> ContentLoader { get; set; } [ContentOutputCache] public ActionResult Index() { var page = ContentLoader.Service.Get<StartPage>(ContentReference.StartPage); var settingsPage = ContentLoader.Service.Get<SettingsPage>(page.SettingsPage); string content = settingsPage.RobotsTxtContent; return Content(content, "text/plain"); } }
I have the VPP:
I have the folder with this adress: MySite\appdata\RobotsTxt, and 2 files in it:
robots.txt & sitemap.xml
If I don't mistake, when i go to link like: http://localhost/MySite/Robots.txt, I should see a dialog offering to download my file. But I have no this.
What this may be because?