title: how to escape $ in robots.txt Disallow directive?
body: <p>robots.txt handles the <code>$</code> as a special character to identify the end of the pattern.</p>
  
  <p>Though, googlebot is parsing some hrefs from JS templates within script tags e.g:</p>
  
  <pre><code>&lt;a href="${object.path}"&gt; ${object.name}&lt;/a&gt;
  </code></pre>
  
  <p>After encoding it, google bot tries to reach <code>mySite.com/$%7Bobject.path%7D</code> which ends in 404s. </p>
  
  <p>To work around this I want do disallow such urls from being crawled by adding a matching directive to my robots.txt.</p>
  
  <p>But using the $ "as is" doesn't work:</p>
  
  <pre><code>Disallow: /$%7Bobject.path%7D$
  </code></pre>
  
  <p>The only working solution I found was to use the wildcard character:</p>
  
  <pre><code>Disallow: /*%7Bobject.path%7D$
  </code></pre>
  
  <p>Though, I'm really curious if there is a way to escape that particular $ sign?</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Well after some more testing with the google robots.txt testing tool I have some strange results. According to this tool the directive:</p>
  
  <pre><code>Disallow: /*%7Bobject.path%7D$ 
  </code></pre>
  
  <p>won't work for <code>/$%7Bobject.path%7D</code> while other tools tells me it matches (like <a href="https://technicalseo.com/seo-tools/robots-txt/" rel="nofollow noreferrer">https://technicalseo.com/seo-tools/robots-txt/</a>).</p>
  
  <p>What works in google's testing tool is putting the brackets unencoded in the directive:</p>
  
  <pre><code>Disallow: /*{object.path}$
  </code></pre>
  
  <p>I can't make any sense out of it so I've put both version in my robots.txt.</p>