We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    fourroses666 Reply #1, 11 years ago
    I have built a client/user front-end login.
    This works fine, on the page I want to add some links to PDF files.
    These PDF files needs to be protected. Google should not index them!
    I think google will index them, so I searched the web.

    I found 3 ways to protect the PDF files from indexing by google/others.


    1) .htaccess
    <FilesMatch "\.pdf$">
      header set x-robots-tag: noindex
    </FilesMatch>


    2) Use robots.txt to block the files from search engines crawlers
    User-agent: *
    Disallow: /assets/files/ # Block the directory.
    Disallow: *.pdf # Block pdf files. Non-standard but works for major search engines.

    3) Use rel="nofollow" on links to those PDFs
    <a href="file.pdf" rel="nofollow">Download PDF</a>


    Is 3) possible with TinyMCE, I don't see the rel on advanced? Or maybe add it with javascript, if so, how?
    The script needs to change every <a href into <a rel="nofollow" href (in a div with class="protected") and does that actually work?



    Oops, this post is placed in Development, if anyone can move it to general? [ed. note: fourroses666 last edited this post 11 years ago.]
      Evolution user, I like the back-end speed and simplicity smiley
    • I made a script that will do this for you, check out the jsfiddle here

      Good luck.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 9995
        • 1,613 Posts
        fourroses666 Reply #3, 11 years ago
        Thanks again Ben, thats perfect!
          Evolution user, I like the back-end speed and simplicity smiley
          • 9995
          • 1,613 Posts
          fourroses666 Reply #4, 11 years ago
          When the <a> is into a <p> tag it doesn't work sad

          http://jsfiddle.net/fourroses666/k6qrK/1/
            Evolution user, I like the back-end speed and simplicity smiley
          • I modified the code now it will work as long as any link is inside the protected div.

            http://jsfiddle.net/k6qrK/3

            Hope that helps.
              Benjamin Marte
              Interactive Media Developer
              Follow Me on Twitter | Visit my site | Learn MODX
              • 9995
              • 1,613 Posts
              fourroses666 Reply #6, 11 years ago
              You nailed it!
                Evolution user, I like the back-end speed and simplicity smiley