Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have around 500 pages, some of which are simply PDF files, that are meant to be viewed within an iframe on a seperate domain parent page (files are subdomained, however reside on a different server).

What would be the best way to force the following behavior:

If a user visits any page within this subdomain, and that is not in the iframe of the main site, to either show a link to the main site, or force redirect to the main site (301?)

What would be the proper SEO way to make sure that the items hosted on the subdomain are properly referenced to the main domain?

As a side note, the subdomain can use any PHP necessary, however the main domain cannot use PHP (which is why the whole subdomain route is necessary).

share|improve this question

Canonical links would be the "proper" way, I would think. Google even supports an HTTP header for use on PDFs and similar.


share|improve this answer

For ranking purposes you should move away from using an iframe and a sub domain all together. The method forward would be to embed your PDF files on directly onto the pages on the main domain using JS.


I recommend you take a look at pdf.js on github additionally you can view a online demo of pdf.js here. Looks superb and far cleaner than dirty 1990's iframes.

share|improve this answer
hmm, ill check into it - the iframes have caused various other problems, but generally are stuck where they are since the subdomain uses PHP to do alot of stuff with the files, and the main domain does not allow PHP. – NRGdallas Feb 15 '13 at 19:34

You could use .htaccess redirection to the subdomain pages. That redirects to your PHP enabled subdomain and add some variables in your pretty URL and handle using an iframe or not depending on where you come from in a PHP file. This will be the only way to have some decent SEO to these files.

Simple for example:


You can find a lot of examples on the use of .htaccess redirects on StackExchange Pro Webmasters.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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