I need some help with google indexing old PDF pages.

Here is the situation:

  • I have a new URL of new.example.com.
  • The website was rebuilt and the company name has changed.
  • The URL used to be old.example.com.
  • It has been about 7 months since the launch of the new website with the new URL.
  • Google is still indexing PDF pages that show the old URL, and if a user clicks on this PDF/page they will also see the old company name and logo.
  • I put a URL redirect on this PDF/page to go to the new URL, and the PDF will now show the user the new logo.

I have been able to redirect at a URL level and folder level in the past for various reasons.

Any suggestions how I can redirect ALL PDF pages at one time... if that makes sense? The problem is that they are not all in the same folder. Not sure if there is some sort of string/code I can add to the .htaccess file for this type of scenario?

  • Do the old and new domains both point to the same hosting account? Are the URLs of the old and new PDF files the same and it's just the domain name that has changed? (In your question you appear to have also used the term "URL" to refer to the domain name.) – MrWhite Oct 19 '18 at 21:56

If all of the .pdf pages need to redirect to the same page, and provided you don't have any .pdf pages that don't need redirecting, you might be able to use something like the following in your .htaccess file...

RewriteCond %{REQUEST_URI} .*\.(pdf)
RewriteRule ^(.*)/ https://new.example.com/new_page/ [R]

Assuming the old and new domains point to the same hosting account and that the filenames of the PDF files themselves have not changed and are located on the same URL-path at the new domain then you can redirect all .pdf files from the old domain to the new (regardless of where they are located), with the following at the top of your .htaccess file:

RewriteCond %{HTTP_HOST} =old.example.com
RewriteRule \.pdf$ https://new.example.com%{REQUEST_URI} [R=302,L]

If the old domain points to a different host then you can remove the condition that checks the requested hostname.

This is a 302 temporary redirect. Change it to a 301 (permanent) redirect only once you have confirmed it is working OK.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.