How to easily hide (Noindex) PDF files in WordPress

Want to hide your PDF files from search engines?

Maybe you run an online business selling ebooks and want to prevent people from finding the file through search engines. Or you can store confidential information in those PDF documents that should not be publicly available.

In this article, we will show you how to hide (noindex) PDF files in WordPress.

Why should you hide (Noindex) your PDF files?

PDFs are one of the most popular file formats, and there are many benefits to uploading them to your WordPress site.

PDF files are often used to build an email list. Many people turn their long blog tutorials into PDF files and then offer them as exclusive content on their website.

PDF files are also used as part of an online course or membership site to offer exclusive premium content to paying subscribers.

If you use PDF files on your website in a similar way, it is better to hide your PDF files from search engines.

You don’t want people to find your PDF files through search results, where users will be able to access your PDF files without giving you their email addresses or payments.

You may also have files containing sensitive data that should not be searched by the public. Hiding those PDF files with Noindex is essential for protection and data security.

With that being said, let’s show you how you can easily hide your PDF files from search engines.

  • Method 1: How to Hide (Noindex) Your PDF Files with AIOSEO (Recommended)
  • Method 2: How to hide (Noindex) your PDF files using X-Robots-tag
  • Bonus: How to Protect PDF File Download in WordPress (3 Ways)

Method 1: How to Hide (Noindex) Your PDF Files with AIOSEO (Recommended)

The best way to hide your PDF files from search engines is to use the AIOSEO plugin.

All in One SEO (AIOSEO) is the best WordPress SEO plugin that allows you to easily optimize your WordPress site for search engines and social media platforms.

This plugin also allows you to easily edit your Robots.txt file, which instructs bots about your site. You’ll add a bit of code that tells them to ignore your PDF files.

The first thing you need to do is install and activate AIOSEO. For further instructions, you can see our guide on how to install a WordPress plugin.

Next, you need to create AIOSEO for your website. If you need help, you can follow our step-by-step guide on how to properly set up All in One SEO in WordPress.

Once the plugin is activated, go to All in One SEO ยป Tools In the WordPress dashboard.

Now that you are on the Tools page, go to the Robots.txt Editor section and click the switch next to Enable Custom Robots.txt.

Enable the Enable Custom Robots.txt button

After that, scroll down to where it says “User Agent” and just add an asterisk

apply the rule to all bots that crawl your site. /pdf/ Then select Allow option under Rule. This will allow all user agents to access PDF files. Now, all you have to do is enter the directory path. Just add it

In the Directory Path field. Note:

If you have saved your PDF directory folder under a different name, you must write that exact PDF directory name in the

Complete the Rule Builder fields

Next, just scroll down and click the Save Changes button.

Once this is done, you will be able to view your rules in the

Robots.txt Preview box

Your robots.txt file will now tell search engines to ignore all PDF files present in your PDF directory folder.

If you want to hide only individual PDF files, you just need to enter the name of that PDF in the

Example for the specific PDF you want to hide example-pdf.pdf For example, as you can see in the image above, entering the

will prevent that one PDF file from being indexed without affecting others.

You can also add a rule like Allow: /*.pdf$ to hide the entire PDF from search engines, but this will only work when User-agent is set to Googlebot. Not all search engines respect such broad rules.

Method 2: How to hide (Noindex) your PDF files using X-Robots-tag X-Robots-tag If for some reason the previous method does not work, then you can use

to hide your PDF files. X-Robots-tag With this method, you will need to manually edit your WordPress site’s .htaccess file and add


First, simply connect to your site using any FTP client or using the file manager application in your WordPress hosting control panel.

Next, locate your .htaccess file, which will be in the same folder as your /wp-content/ and /wp-admin/ folders.

If you can’t find the .htaccess file, you can follow our tutorial on why you can’t find the .htaccess file to make it visible.

For this tutorial, we will use FileZilla as our FTP client. After connecting to your site, you’ll find your .htaccess file under “Remote Site” in the right-hand column.

Once you find the .htaccess file, right-click and open the View/Edit option.

view-htaccess-file X-Robots-tagThis will open the file in a text editor. If you’re using Notepad, here’s how it might look after you add it


X-robots-tag in Notepad X-Robots-tag If you are using an Apache server, just add the following:

<Files ~ "\.pdf$">
Header set X-Robots-Tag "noindex, nofollow"

in the .htaccess file.

location ~* \.pdf$ 
add_header X-Robots-Tag "noindex, nofollow";

If you are using an Ngnix server, add the following:

Once you’ve added the X-robots-tag, just save your file. This will now mark all .PDF files as noindex/nofollow, which means you have successfully hidden your PDF files from search engines.

Bonus: How to Protect PDF File Download in WordPress (3 Ways)

The two methods above cover how to hide PDF files from search engines, but if you want to further restrict PDF downloads to members only, require a password or email address to download PDFs, or even collect payments, you’ll need one of the following tools:

1. MemberPress

MemberPress is the best WordPress membership plugin on the market. It allows you to restrict access to the PDF file to registered members only. You can even sell access to PDF files based on different user subscription levels.

MemberPress also allows you to create and sell online courses, and often site owners offer premium PDF guides with their courses.

Basically, this method will ensure that your PDF files are fully protected and no one will be able to access your PDF file if they enter a password and log in.

2. Easy digital downloads

Easy Digital Downloads is a popular WordPress eCommerce plugin that helps you sell digital products like PDF files, eBooks, and more.

It comes with maximum file protection features for PDF files, so you can store it in a private cloud, create unique access links for each member, track download activity, limit the number of downloads of a specific file, and more.

You can accept payment via credit card, PayPal, and more, so you can restrict PDF access by user subscription level.

3. OptinMonster

OptinMonster is the best lead generation plugin for WordPress. It helps you get more email subscribers and sales from your website visitors.

Many website owners use OptinMonster to require the user to enter an email address before they can access their PDF files.

This process is called lead magnet delivery or content optimization. When a user enters their email address into OptinMonster, they will be added as a subscriber to your email marketing service or CRM.

They will then receive access to the PDF file in a personalized welcome email.

We hope this article helped you learn how to hide (noindex) your PDF files from search engines. You can also see our guide on how to create an email list in WordPress and check out our article on how to stop search engines from crawling your WordPress site. If you enjoyed this article, please subscribe to our YouTube channel for WordPress video tutorials. You can also find us Twitter:

and Facebook.

How to Easily Hide (Noindex) PDF Files in WordPress appeared first on WPBeginner.

Leave a Reply