Skip to content

Keeping a staging site private and out of search results

Reviewed on 26 November 2026

Use two layers. A password stops strangers from opening the copy at all. A noindex rule tells search engines not to list it. Either one alone leaves a gap.

Two layers of protectionPut a password in front of the copyAdd a noindex ruleLeave robots.txt alone for noindexVisit the copy while logged outSearch for the address to check
A password stops visitors. Noindex asks search engines to stay out.

What you need

  • Access to your host's control panel, or to your site's files.
  • Your host's help page on password protection or staging privacy.
  • A way to visit the copy while logged out, such as a private browser window.

Layer one: a password

A password in front of the whole copy keeps out visitors, bots and anyone who guesses the address. Many hosts and plugins offer this as a setting. Look for "password protect", "site lock" or similar words in your host's panel.

On a server running Apache, the documentation describes the long way. You create a password file, then add directives such as AuthType Basic and AuthUserFile to a .htaccess file or the server settings.1 Follow the Apache page itself for the exact steps, because paths and options depend on your setup.

The same page carries a warning.1 It says that "Basic authentication sends the password from the client to" the server unencrypted, so it shouldn't be used for highly sensitive data without an encrypted connection (HTTPS).

So make sure your test address loads over HTTPS before you rely on a password.

Two more points on passwords:

  • Don't reuse your live site's password for the copy. Kinsta notes that if a staging site is a clone,2 "your WordPress admin login credentials will be the same for both your live and staging sites unless you change them". Change them after cloning.
  • Keep the password to the people who need it. Don't paste it into emails or public chats.

Layer two: noindex

Noindex is a rule that asks search engines not to list a page. Google explains it as a rule you can add as a <meta> tag in the page's head. It can also arrive as an HTTP header.3 The page says "Instead of a tag, you can return an X-Robots-Tag" header with the value noindex.

If you use WordPress, there's a built-in switch. In Settings, then Reading, you'll find a box. WordPress's documentation says to4 "Check the Discourage search engines from indexing this site box to ask search engines not to index this site."

Note the wording: it asks. The same page adds that4 "it is up to search engines to honor your request." Noindex is a polite request, not a lock. That's why the password matters.

Some hosts set it up for you. Kinsta says2 "By default, indexing is turned off for Staging sites". Check what your host does rather than assuming. A plugin may add its own noindex handling too.

Why robots.txt isn't the answer

It's tempting to block the copy with a robots.txt file. Google warns against that:5 "Don't use a robots.txt file as a means to hide your web pages" from search results. It suggests that you5 "use another method such as password protection or" noindex.

There's a second catch. For noindex to work,3 the page "or resource must not be blocked by a robots.txt file". If a crawler can't read the page, it never sees the noindex rule.

So don't stack a robots.txt block on top of noindex and assume you're doubly covered. You might be cancelling the rule out.

Check it worked

Do this on the copy, once the layers are in place:

  • Open the address in a private window. You should hit the password prompt.
  • View the page source and look for the noindex tag, or ask your host how the header is sent.
  • Search for the address in a search engine after a while. It shouldn't appear.

If the copy already showed up in search results, the noindex rule works only after the crawler visits again. Don't expect it to vanish the same hour.

When changes go live

The privacy settings are meant for the copy only. After you move changes to the real site, check that the live site isn't hidden from search engines and isn't asking visitors for a password. The page on sending changes live covers the move, and the checklist includes this check.

Reference list

  1. Authentication and Authorization, Apache HTTP Server documentation
  2. Staging Environments, Kinsta
  3. Block Search Indexing with noindex, Google Search Central
  4. Settings Reading Screen, WordPress.org documentation
  5. Introduction to robots.txt, Google Search Central