I need some help with google indexing old PDF pages.
Here is the situation:
new.example
.old.example
.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?
I need some help with google indexing old PDF pages.
Here is the situation:
new.example
.old.example
.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?
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/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
RewriteRule \.pdf$ https://new.example%{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.