Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Luke Hook 8 posts 78 karma points
    Apr 12, 2019 @ 10:20
    Luke Hook

    Robots.txt edit in CMS - URL rewrite to handle file extension?

    Hi guys,

    I'm building a site for a client who has quite specific requirements around being able to edit their Robots.txt file (amongst other things).

    I've been following this really handy article by glcheetham

    However I obviously come across issues when it comes to rewriting the URL to handle the file extension as UrlRewriting.config no longer exists.

    Does anybody know of an alternative way to do this or better yet an IIS Rewrite rule I can use instead that will achieve the same result as this.

    <add name="robots-rewrite" virtualUrl="^~/robots.txt" destinationUrl="~/robotstxt"/>

    Apologies if this a simple query, my rewrite skills are not the greatest :)

  • Søren Gregersen 282 posts 1138 karma points MVP c-trib
    Apr 12, 2019 @ 21:09
    Søren Gregersen

    The rule would be something like

    <rule name="robots.txt">
      <match url="^robots.txt$"/>
      <action type="Rewrite" url="~/robotstxt" />

    The "^" in url means "start of input", and "$" is end of input. The url is everything between the first "/" and first "?" in the url. This will then match, but not

    HTH :)

Please Sign in or register to post replies

Write your reply to: