Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Would you be willing to share the source code for this project with us? We're looking to implement a dynamic robots.txt file but it would need to handle some special use cases.
Thanks
Zac
Hey Zac,
Looks like I kinda lost the source code for this, but not to worry, a little decompile helped, this is all there is to it:
using System;using System.IO;using System.Web; namespace Cultiv.DynamicRobots{ public class RobotsTxt : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var path = HttpContext.Current.Server.MapPath(VirtualPathUtility.ToAbsolute("~/robots.txt")); if (File.Exists(path)) { var streamReader = File.OpenText(path); var text = streamReader.ReadToEnd(); context.Response.Write(text.Replace("{HTTP_HOST}", HttpContext.Current.Request.ServerVariables["HTTP_HOST"])); streamReader.Close(); streamReader.Dispose(); } else { context.Response.Write(""); } } } }
Thanks!
if a site is multilingual, like "mysite.com/de", what should be instead of "HttpContext.Current.Request.ServerVariables["HTTP_HOST"]"?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Source code?
Would you be willing to share the source code for this project with us?
We're looking to implement a dynamic robots.txt file but it would need to handle some special use cases.
Thanks
Zac
Hey Zac,
Looks like I kinda lost the source code for this, but not to worry, a little decompile helped, this is all there is to it:
Thanks!
if a site is multilingual, like "mysite.com/de", what should be instead of "HttpContext.Current.Request.ServerVariables["HTTP_HOST"]"?
is working on a reply...