Hi, I am going to submit a new website in Google (deveoped in PHP) today.
I have 'include' folder which has header.php, footer.php and navigation.php files.
I have included them in each web page of my site using <?php include ('./includes/header.php'); ?>.
I do not want these php files to be indexed separate in Google so-
Can I block include folder and If I block hearder/footer/navigation, will it effect the pages?
Will all my pages indexed as usual with html in header/footer/navigation?

Since I have completed my website so I can not do major change now :)

thanks for coming solutions

Dani AI

Generated

Short answer: do not rely on robots.txt to hide your PHP includes. Because header/footer files are brought into pages server‑side, Google normally indexes the final HTML output — not the include call itself — and blocking the includes directory with robots.txt can produce odd results (Google may still show the include URL as a link‑only result and crawlers won't see any on‑page noindex). Use robots.txt only for crawl control, not as a privacy or deindexing tool. Google: block/indexing guidance. (developers.google.com)

Recommended practical fixes (simple → stronger):

  • If possible, move your include files outside the web root so they cannot be requested directly (best practice for PHP apps).
  • If you cannot move them, stop direct HTTP access to the includes folder via server config (.htaccess on Apache). Example (place in the includes folder or the site config):
# Apache 2.4
<IfModule mod_authz_core.c>
  Require all denied
</IfModule>

# Apache 2.2 fallback
<IfModule !mod_authz_core.c>
  Order Deny,Allow
  Deny from all
</IfModule>
  • Add a tiny guard at the top of each include so it exits on direct requests (return 403/404) rather than revealing HTML.
    These approaches prevent the include files from appearing as standalone pages and are recommended over using robots.txt. . (httpd.apache.org)

Quick checklist for (and following up on ): do not disallow the includes folder in robots.txt if you want predictable indexing. Instead: protect the folder (move it or deny direct access), verify with Google Search Console URL Inspection (use the live render to check what Google sees), and if you need immediate removal of already indexed include URLs use the Search Console Removals tool while you fix the site. Also avoid blocking CSS/JS/images that pages need to render correctly. [Search Console removals and guidance]. (developers.google.com)

Recommended Answers

All 2 Replies

Member Avatar for Member #949455

Should I block header and footers PHP files from Robots.txt

I'm not sure what do you mean by block? It should be the page (index.php)

I don't put anything in my include only header/footer/db/functions.

Try this:

Sorry, Block mean blocking from being indexed in Google using robots.txt.Thanks I read the link website but could not found exact solution. By the way I have submitted site lets see what comes out. I wll share bad / good here

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.