In short
During a redesign, the staging site contains the complete future site: it must stay invisible to Google, Bing and AI crawlers, but accessible to the team and to the tools that audit it. This task does both: server-side authentication with an entrance reserved for tools (IP address or secret token), then a full crawl of the staging site checked against a checklist. Once the task is done, an anonymous request receives 401 or 403, your crawler explores the whole site, and the list of settings to switch on launch day is written down.
Why it matters
An open staging site gets indexed: Google finds a duplicate of the future site there and may even prefer it to production. Its unpublished content can also be collected by AI crawlers and come up in an answer before your launch. The protection itself is covered in detail in protect staging and private data with authentication (opens in a new tab); here, the concern is the redesign.
A staging site closed to everyone raises a different problem: it cannot be audited. Yet this is the only moment when mistakes are cheap. Once live, a noindex forgotten in a template, a canonical pointing to the staging host or a menu that no longer links to a section costs you pages dropped from the index for weeks.
The classic trap is that staging protections are often settings of the site itself: WordPress's “discourage search engines” checkbox, Disallow: / in robots.txt, a noindex tag in the template. They go to production along with everything else. In its documentation on site moves, Google reminds you to remove crawl blocks and temporary noindex directives at launch.
What it improves
- Indexing No staging pages in the results, no duplicates of the future site.
- Confidentiality Unannounced content and prices are read neither by search engines nor by AI crawlers.
- Launch quality SEO mistakes are found by the acceptance crawl, not by Search Console after the fact.
- Safe switchover Staging-specific settings are listed and do not go to production.
- Rankings No direct gain; the task avoids the most severe losses of a redesign.
How to check
Anonymous request, then authenticated request:
curl -s -o /dev/null -w "%{http_code}\n" https://preprod.example.com/
curl -s -o /dev/null -D - -u utilisateur:motdepasse https://preprod.example.com/ | grep -i -E "^(HTTP|x-robots-tag)"
Correct result:
401
HTTP/2 200
x-robots-tag: noindex, nofollow
If you use a token for tools, test it as well:
curl -s -o /dev/null -w "%{http_code}\n" -H "X-Audit-Token: JETON_SECRET" https://preprod.example.com/
Expected: 200. Finally, check that the current production site carries none of these settings: curl -sI https://www.example.com/ | grep -i x-robots-tag must return nothing.
How to implement
Before you start
Four rules apply to every environment:
- Protect at the server level, not in the site: HTTP authentication, IP-based access or an identity gateway. The
X-Robots-Tag: noindexheader is only a second line of defence. robots.txt protects nothing. - Let tools in through a list of IP addresses or a secret header, rather than opening the staging site for the duration of a crawl.
- Make every difference depend on the environment: hostname,
noindex, robots.txt and analytics ID are set by an environment variable, never hard-coded in templates. - Keep staging close to production: same templates, same plugins, same volume of content, same redirects. An audit of an incomplete staging site validates a site that does not exist.
Apache
Versions Apache 2.4.
In the staging virtual host, first create the password file with sudo htpasswd -c /etc/apache2/.htpasswd-preprod recette, then:
<Location "/">
AuthType Basic
AuthName "Preproduction"
AuthUserFile /etc/apache2/.htpasswd-preprod
<RequireAny>
Require ip 203.0.113.10
Require expr "%{HTTP:X-Audit-Token} == 'JETON_SECRET'"
Require valid-user
</RequireAny>
</Location>
Header always set X-Robots-Tag "noindex, nofollow"
203.0.113.10 is the fixed address of the computer or server that runs the crawls. Reload with sudo apachectl configtest && sudo systemctl reload apache2.
Nginx
Versions Nginx 1.24 and later.
In the http context, work out whether authentication applies: it is turned off (off) for the allowed IP or for the right token.
geo $preprod_ip_autorisee {
default 0;
203.0.113.10 1;
}
map "$preprod_ip_autorisee:$http_x_audit_token" $preprod_auth {
default "Preproduction";
"~^1:" off;
"0:JETON_SECRET" off;
}
Then in the staging server block:
server {
server_name preprod.example.com;
auth_basic $preprod_auth;
auth_basic_user_file /etc/nginx/.htpasswd-preprod;
add_header X-Robots-Tag "noindex, nofollow" always;
# … rest of the configuration
}
The password file is created with htpasswd (apache2-utils package). Reload with sudo nginx -t && sudo systemctl reload nginx.
Cloudflare
Versions Cloudflare dashboard, Zero Trust, November 2026.
Put the staging site behind Cloudflare Access: in Zero Trust, Access controls > Applications, add a self-hosted application on preprod.example.com with an “Allow” policy for the team's email addresses. For tools, create a service token (Access controls > Service credentials > Service Tokens) and a second policy whose action is “Service Auth”; without that action, Access asks for a login. The crawler then sends with every request:
CF-Access-Client-Id: IDENTIFIANT_DU_JETON
CF-Access-Client-Secret: SECRET_DU_JETON
Add the X-Robots-Tag header with a response header transform rule, limited to the staging hostname.
Vercel
Versions Vercel, all plans, November 2026.
In the project settings, Deployment Protection, check that preview deployments are protected (Vercel Authentication or password, depending on the plan). For tools, generate a secret under “Protection Bypass for Automation”, available on all plans, and send it in the x-vercel-protection-bypass header. Add x-vercel-set-bypass-cookie: true so that an automated browser keeps access on subsequent pages.
Netlify
Versions Netlify, Pro and Enterprise plans, November 2026.
Password protection is set in the project configuration, under Visitor access; Pro plans let you limit it to previews. Another method on Pro plans is basic authentication in the _headers file of the published folder of the staging branch:
/*
Basic-Auth: recette:MOT_DE_PASSE
X-Robots-Tag: noindex, nofollow
WordPress
Versions WordPress 6.4 and later.
Protect at the server level or through the host (most managed WordPress hosts offer a protected staging environment). Declare the environment type in the staging site's wp-config.php:
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
Plugins that take it into account (caching, email, analytics) then adapt their behaviour. If you tick “Discourage search engines from indexing this site” under Settings > Reading on the staging site, add it to the switchover list: this option is stored in the database and goes along with it if the database is copied to production.
Laravel
Versions Laravel 12 and 13.
A middleware that protects every environment except production, with a token for tools:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class ProtectStaging
{
public function handle(Request $request, Closure $next): Response
{
if (app()->isProduction()) {
return $next($request);
}
$token = (string) config('services.staging.audit_token');
$hasToken = $token !== '' && hash_equals($token, (string) $request->header('X-Audit-Token'));
$hasCredentials = hash_equals((string) config('services.staging.user'), (string) $request->getUser())
&& hash_equals((string) config('services.staging.password'), (string) $request->getPassword());
if (! $hasToken && ! $hasCredentials) {
return response('Restricted access', 401, ['WWW-Authenticate' => 'Basic realm="Preproduction"']);
}
$response = $next($request);
$response->headers->set('X-Robots-Tag', 'noindex, nofollow');
return $response;
}
}
Declare the staging.user, staging.password and staging.audit_token keys in config/services.php (read from .env), then register the middleware in bootstrap/app.php: $middleware->prepend(ProtectStaging::class); inside withMiddleware().
Crawling the staging site
With Screaming Frog:
Configuration > Authentication: basic authentication credentials, or login form.Configuration > HTTP Header: theX-Audit-Tokenheader, or the two Cloudflare token headers, orx-vercel-protection-bypass.Configuration > robots.txt: choose to ignore robots.txt if the staging site blocks everything.- The same JavaScript rendering setting as for the pre-redesign crawl (opens in a new tab), so that you compare like with like.
Then run the old URLs from the redirect map in list mode: they should already redirect correctly on the staging site.
Checklist
| Check | Expected on staging | Switchover point |
|---|---|---|
| Anonymous access | 401 or 403 on every URL | 200 in production |
X-Robots-Tag and meta robots |
noindex via header, no noindex in the templates of indexable pages |
No noindex left except on deliberately excluded pages |
| robots.txt | Production version ready in the repository | Production version live; see check canonicals, hreflang, sitemaps and robots.txt (opens in a new tab) |
| Canonical, hreflang, sitemap | Built from the current hostname, never hard-coded | Production hostname everywhere |
| Internal links | No absolute links to the staging host or to the old domain | Same |
| HTTP status codes | Pages return 200; a made-up URL returns 404 | Same |
| Old URLs | Single-step redirect according to the map; see test redirects (opens in a new tab) | Same |
| Titles, H1s, content, internal links | Parity with the old site; see preserve strategic content and internal links (opens in a new tab) | Same |
| Structured data and anchors | Parity with the old site; see preserve structured data, entity identifiers and anchors (opens in a new tab) | Production hostname in @id values |
| Analytics | Disabled or test property | Production property; see check tracking (opens in a new tab) |
| Performance | Measured; see test performance before launch (opens in a new tab) | Same |
Warning: the “Switchover point” column is the list to work through on launch day. Assign it to a named person and tick it off line by line: that is the purpose of the task remove indexing blocks on the live site (opens in a new tab).
Common mistakes
- Protecting the staging site with robots.txt alone: URLs can be indexed without being crawled, and nothing stops a crawler that ignores the file from reading the pages.
- Opening the staging site for the duration of a crawl: a few hours are enough for a link to leak and a crawler to come by.
- Putting
noindexin the templates instead of an environment-dependent server header: it goes to production with the code. - Copying the staging database to production with WordPress's “discourage search engines” option ticked.
- Auditing an incomplete staging site: without the real content and redirects, the crawl validates a different site from the one that will go live.
- Leaving the production analytics tag on the staging site: acceptance-testing visits skew the baseline figures.
- Comparing crawls with different settings: JavaScript rendering or user agent changed between the old site and staging.
Frequently asked questions
How do you crawl a password-protected staging site?
Give the credentials to your crawler rather than opening the staging site. Screaming Frog accepts basic authentication and login forms in its configuration, as well as custom HTTP headers for an access token. On the server side, you can also allow the fixed IP address of the machine that crawls, or a secret header, as Apache, Nginx, Cloudflare Access service tokens and Vercel's automation bypass all make possible.
Is noindex enough to protect a staging site?
No. The noindex directive prevents a crawled page from being indexed, but it does not stop anyone from reading the page, nor an AI crawler from collecting its content. A staging site is protected by server-side authentication, which returns 401 or 403 to any anonymous request. The X-Robots-Tag noindex header remains useful as a second line of defence, in case the protection is lifted by mistake.
What should you check on the staging site before launch?
Crawl the whole staging site and check status codes, noindex in templates, canonicals and hreflang, internal links to the staging host, redirects of old URLs, parity of titles, content, internal links and structured data with the old site, and performance. Also prepare the list of staging-specific settings to switch on launch day: noindex, robots.txt, protection and analytics.
Resources
- Google Search Central: Block search indexing with noindexdevelopers.google.com
- Google Search Central: Site moves with URL changesdevelopers.google.com
- Apache: mod_authz_core and Require exprhttpd.apache.org
- Nginx: auth_basic modulenginx.org
- Cloudflare: Access service tokensdevelopers.cloudflare.com
- Vercel: Protection Bypass for Automationvercel.com
- Netlify: Password protectiondocs.netlify.com
Updated on
Topic checklist (PDF)