Do you want to hide your PDF files from search engines?
You might be running an online business selling ebooks and want to prevent people from finding the file using search engines. Or you might have sensitive information stored in those PDF documents that shouldnโt 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 / how to hide (noindex) PDF files in WordPress
PDFsย are one of the most popular file formats, and there are many benefits of uploading them on your WordPress website.
PDFs are often used toย build an email list. A lot of people convert long tutorials on their blogs into PDFs, and then offer them asย exclusive content on their websites.
PDF files are also used to offer exclusive members-only premium content for paying subscribers as part of an online course orย membership site.
If youโre using PDFs on your website in a similar way, then it is best that you hide your PDF files from search engines.
You do not want people to find your PDF files through search results where users would be able to access your PDFs without providing you with their email addresses or payments.
You might also have files containing sensitive data that shouldnโt be searchable by the public. Hiding those PDFs using 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 Using AIOSEO (Recommended)
The best way to hide your PDF files from search engines is by using theย AIOSEOย plugin.
All-in-One SEO (AIOSEO) is the best WordPress SEO plugin that allows you to easily optimize your WordPress website for search engines and social media platforms.
This plugin also allows you to easily edit yourย Robots.txt file, which gives bots instructions about your site. You will be adding a bit of code that will tell them to ignore your PDFs.
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 will need to set up AIOSEO for your site. If you need help, then you can follow our step-by-step guide onย how to set up All in One SEO in WordPress correctly.
Once the plugin is activated, head over toย All in One SEO ยปย Toolsย in the WordPress dashboard.
Now that youโre on the โToolsโ page, head over to the โRobots.txt Editorโ section and click the toggle present beside โEnable Custom Robots.txt.โ
After that, scroll down to where it says โUser Agentโ and simply add an asterisk (*) to apply the rule to all bots that crawl your site.
Then, select the โDisallowโ option in the โRuleโ section. Doing this will block all of the user agents from accessing the PDF files. Now, all you have to do is enter a directory path. Simply addย /pdf/
in the โDirectory Path field.
Note: If you have saved your PDF directory folder under any other name, then you will have to write that exact PDF directory name in the โDirectory Path field.
ย
Next, just scroll down and click on the โSave Changes button.
Once thatโs done, youโll be able to view your rules in the โRobots.txt Previewโ section of the page.
ย
Your robots.txt file will now tell search engines to ignore all the PDF files that are present in your PDF directory folder.
If you only want to hide individual PDF files, then you will need to simply type the name of that PDF in the โDirectory Path field.
For example, as you can see in the image above, enteringย example-pdf.pdf
ย will prevent that single PDF file from being indexed without affecting others.
You can also add a rule like Disallow: /*.pdf$ to hide all PDFs from search engines, but this will only work when User-agent is set to Googlebot. Not all search engines respect a broad rule like that.
Method 2. How to Hide (Noindex) Your PDF Files Using X-Robots-tag
If for some reason the previous method doesnโt work, then you can use theย X-Robots-tag
ย to hide your PDF files.
In this method, you will need to manually edit your WordPress siteโsย .htaccess fileย and addย X-Robots-tag
ย to it.
First, simply connect to your website using anyย FTP clientย or by using the file manager app on 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 cannot find the .htaccess file, then you can follow our tutorial onย why you canโt find the .htaccess fileย to make it visible.
For this tutorial, we will be using FileZilla as an FTP client. Once connected to your site, you will find your .htaccess file in the โRemote Siteโ section in the right-hand column.
Once you locate the .htaccess file, right-click and open the โView/Edit option.

This will open the file in a text editor. If you are using Notepad, here is how it may look after youโve added theย X-Robots-tag
.

If youโre using an Apache server, then simply add the following X-Robots-tag
ย in the .htaccess file.
<Files ~ "\.pdf$"> Header set X-Robots-Tag "noindex, nofollow" </Files>
If youโre using the Ngnix server, then add the following:
location ~* \.pdf$ { add_header X-Robots-Tag "noindex, nofollow"; }
Once youโve added the X-robots-tag, simply save your file. This will now mark all. PDF files as index/nofollow, which means youโve succeeded in hiding your PDF files from search engines!
Bonus: How to Protect PDF File Download in WordPress (3 Ways)
The above two methods 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, then you will need one of the following tools:
1. MemberPress
MemberPressย is theย best WordPress membership plugin in the market. It allows you to restrict PDF file access to registered members only. You can even sell access to PDF files based on different subscription levels the user has.
MemberPress also lets youย create and sell online coursesย and often website owners offer premium PDF companion 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 unless they enter a password and log in.
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, generate unique access links for each member, track download activity, limit the number of times a specific file can be downloaded, and more.
You can accept payments via credit card, PayPal, and others, so you can restrict PDF access by userโs subscription level.
OptinMonster is theย best lead generation pluginย for WordPress. It helps you get more email subscribers and sales from your website visitors.
A lot of website owners use OptinMonster to require users to enter an email address before giving them access to their PDF files.
This process is called delivering a lead magnet orย content upgrade. Once the user enters their email address in OptinMonster, theyโre added as a subscriber in yourย email marketing serviceย or CRM.
After that, theyโll get 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 may also want to see our guide onย how to build an email list in WordPressย and check out our article onย how to stop search engines from crawling a WordPress site.
ย