Hi,
I've done a search and came up with nothing.
Here's my problem, I have a site that uses an index.htm page as the homepage and an iframe contained in that page that is dynamic and is the only content that changes.

Everything works fine except in web search engines, my iframe pages are coming up as results(They need the navy background from the index.htm page to see the white text)ie. i only want the index.htm page to show up. i have meta tagtrying to stop the crawling of these pages by the search engines band robots.txt in the web folder on the server but this isint stopping them being indexed.

So what i need to know is, is there any way to do the following....

when a user clicks on a google search result of one of my iframes, that it instead opens up the just the index page or better again the index page with the iframe that was clicked actually in the iframe. That might not make sense...hopefully it does im really stuck.
I realise i shouldnt have used iframes really :(

Dani AI

Generated

Short diagnosis and where the problem comes from — your iframe pages are real URLs and search engines can index them separately from your index.htm. That’s why search results land on the framed page (which looks wrong without the parent’s styling). is correct that where the iframe src is hosted affects what gets indexed; ’s frame‑busting idea can work for users, but it’s brittle and not a reliable SEO fix. Also: blocking via robots.txt alone won’t reliably remove a URL from search results because crawlers can’t see a page’s noindex if you block it. (developers.google.com)

Practical, ordered fixes you can apply now:

  1. Best long term — stop using an iframe for main content. Serve the changing content within index.htm (server‑side includes, templates, or server‑rendered SPA routing). That guarantees one URL and avoids framing issues.
  2. If you can’t rebuild, tell search engines not to index the iframe pages (and keep them crawlable): add an X-Robots-Tag: noindex HTTP header on the iframe source files (don’t block them in robots.txt). Alternatively, on each iframe page add a rel="canonical" pointing to index.htm so search engines prefer the parent URL. For cases where you want embedded content indexed only when embedded, Google’s indexifembedded exists but is Google‑only. (developers.google.com)

Examples (place on the iframe source pages or server config):

<!-- in the iframe page head -->
<link rel="canonical" href="https://example.com/index.htm" />
# in .htaccess to add a noindex header for iframe files
<FilesMatch "\.(html|php)$">
  Header set X-Robots-Tag "noindex, nofollow"
</FilesMatch>

If you want clicks on an indexed iframe URL to open the parent with that content selected, implement a server‑side 3xx redirect from the iframe URL to index.htm?panel=... (server redirects are faster and more reliable for crawlers than client JS redirects). Avoid relying on JS frame‑busting alone — it’s handled inconsistently by crawlers and browsers. After making changes, request a recrawl in Search Console and use the temporary removal tool if you need urgent clearing. (developers.google.com)

Troubleshooting checklist: 1) remove any robots.txt Disallow that blocks the iframe files so crawlers can see noindex; 2) confirm headers/meta with a fetch or URL Inspection; 3) request recrawl and monitor coverage. If you post the site URL, the community can point to exactly which file to change.

Recommended Answers

All 2 Replies

Please supply link to your site, I can have a look and see if I can help. It will all depend where the iframe is pointing to, maybe another site/domain? If that is the case, search engines index the original site, not the page where it is framed into.

Hi,
blocking the page in the robots.txt and preventing the pages to be listed using the meta tag <meta name="robots" content="NoIndex, NoFollow" /> is in some cases not enough. You can use a javascript to prevent the page within the iframe to be displayed as the top window. In this case the search engine may show your page, but once a user clicks on the page, he finds your page within the desired index.htm.


You can use the following code:

<script language="javascript">
if (parent.location.href == self.location.href) {
window.location.href = 'default.asp';
}
</script>

The above code would make the homepage appear each time. To prevent this, you can put a dynamic querystring in order to display the desired page:

<script language="javascript">
if (parent.location.href == self.location.href) {
window.location.href = 'default.asp?iframe_page='+self.location.href;
}
</script>

Good luck,
Ali Baradaran

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.