# Protect private content with authentication

- Check 31.20 · AI crawler access and data policy · Critical
- Source: https://checklist-seo-geo.com/en/ai-crawler-access-data-policy/protect-private-content-authentication
- Protect customer areas, documents and staging with real authentication on Apache, Nginx, Caddy, Cloudflare, AWS, Vercel, WordPress or Laravel.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/ai-crawler-access-data-policy/protect-private-content-authentication.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Neither robots.txt, nor the `noindex` tag, nor a hard-to-guess URL protects content. The only way to prevent a crawler, an AI assistant or a stranger from reading a page is to require authentication on the server side before sending a single byte. Once this check is done, every private resource (page, file, API, staging site) responds with a 401 or a 403, or redirects to the login page, when the request is anonymous.

## Why it matters

Three misconceptions explain most leaks.

**“It's disallowed in robots.txt.”** robots.txt is an instruction that crawlers choose to follow, and a public file: listing `/intranet/` or `/factures/` in it amounts to publishing the map of your sensitive areas. User-triggered fetchers also act at a user's request: OpenAI states that robots.txt rules may not apply to ChatGPT-User, and Perplexity that Perplexity-User generally ignores them. If someone pastes a document's URL into an assistant, the assistant will go and fetch it.

**“The page is set to noindex.”** `noindex` asks a search engine not to show the page in its results. It does not prevent anyone from downloading it, and it says nothing to crawlers that do not build a search index.

**“Nobody knows the URL.”** URLs leak: referrers, shared histories, messaging apps, browser extensions, automatically generated sitemaps, certificate transparency logs for subdomains. An open `staging` subdomain almost always ends up being crawled.

Anything accessible without authentication must be considered public: liable to be indexed, cited in a generative answer or collected to train models. Protection is therefore a prerequisite for any data policy, not an SEO setting.

## What it improves

- **Confidentiality**: customer data, internal documents and test environments can no longer be read by a crawler or a third party.
- **Control over what AI says**: unpublished content cannot resurface in a generative answer.
- **Clean indexing**: staging no longer competes with the real site in the results. See [protect staging and private data with authentication](https://checklist-seo-geo.com/en/indexing-canonicalization/protect-staging-private-data-authentication).
- **Compliance**: personal data protection relies on access control, not on an instruction to crawlers.
- **Rankings**: no direct effect; the indirect effect is avoiding duplicate content and worthless pages in the index.

## How to check

**1. Anonymous request on each private area:**

```bash
curl -s -o /dev/null -w "%{http_code} -> %{redirect_url}\n" https://example.com/espace-client/
curl -s -o /dev/null -w "%{http_code} -> %{redirect_url}\n" https://staging.example.com/
```

Compliant result: `401`, `403`, or a redirect to the login page. A `200` means the content is public.

**2. Direct access to files.** Pages are often protected, but not the files they link to:

```bash
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/storage/factures/2026-0001.pdf
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/wp-content/uploads/2026/11/contrat.pdf
```

**3. APIs and feeds.** Test the endpoints that return data without a token: `/api/…`, `/wp-json/wp/v2/users`, CSV exports.

**4. What is already exposed.** In Google and Bing, search for `site:staging.example.com` and `site:example.com inurl:espace-client`. Review your robots.txt: every sensitive path listed in it must be protected by other means.

**5. In the logs**, look for 200 responses served to crawlers on private paths: see [analyze AI crawler logs](https://checklist-seo-geo.com/en/ai-crawler-access-data-policy/analyze-ai-crawler-logs).

## How to implement

### Before you start

- **Authentication applies on the server side**, before the content is sent. Hiding with CSS or JavaScript protects nothing.
- **Respond with a real error code**: 401 with the `WWW-Authenticate` header for HTTP authentication, 403, or a redirect to the login page. Not a 200 with a “please log in” message.
- **Always over HTTPS**: HTTP Basic authentication sends the credentials with every request.
- **Protect files as much as pages**: store them outside the web root and serve them through the application after a check.
- **Prevent shared caching** of authenticated responses: `Cache-Control: private, no-store`.
- **Remove sensitive paths from robots.txt and sitemaps** once protection is in place.

HTTP Basic authentication is suitable for staging and small internal areas. For a customer area, use the application's authentication or an identity provider.

### Apache

Versions: Apache 2.4.

Create the password file outside the web root (`apache2-utils` package), then protect the host or the directory:

```bash
sudo htpasswd -c /etc/apache2/.htpasswd equipe
```

```apache
<Directory "/var/www/staging">
    AuthType Basic
    AuthName "Restricted access"
    AuthUserFile /etc/apache2/.htpasswd
    Require valid-user
</Directory>
```

To exempt an office address from the password:

```apache
<Directory "/var/www/staging">
    AuthType Basic
    AuthName "Restricted access"
    AuthUserFile /etc/apache2/.htpasswd
    <RequireAny>
        Require ip 203.0.113.10
        Require valid-user
    </RequireAny>
</Directory>
```

In a `.htaccess` file, the same directives are written without the `<Directory>` block.

```bash
sudo apachectl configtest && sudo systemctl reload apache2
```

### Nginx

Versions: Nginx 1.18 and later.

```bash
sudo htpasswd -c /etc/nginx/.htpasswd equipe
```

Without `htpasswd`, generate the line with OpenSSL: `printf "equipe:%s\n" "$(openssl passwd -apr1)" | sudo tee -a /etc/nginx/.htpasswd`.

```nginx
server {
    listen 443 ssl;
    server_name staging.example.com;

    auth_basic "Restricted access";
    auth_basic_user_file /etc/nginx/.htpasswd;
    add_header X-Robots-Tag "noindex, nofollow" always;

    root /var/www/staging/public;
}
```

For a single directory, place the two `auth_basic` directives in the corresponding `location` block. Complete the block with your certificate directives, then run `sudo nginx -t && sudo systemctl reload nginx`.

### IIS

Versions: IIS 10 (Windows Server 2016 to 2025).

Install the “Basic Authentication” feature (Web Server role, Security section). In IIS Manager, open `Authentication` on the site: disable “Anonymous Authentication”, enable “Basic Authentication”. The accounts are Windows accounts. The `web.config` equivalent:

```xml
<configuration>
  <system.webServer>
    <security>
      <authentication>
        <anonymousAuthentication enabled="false" />
        <basicAuthentication enabled="true" />
      </authentication>
    </security>
  </system.webServer>
</configuration>
```

These sections are locked by default at the server level: unlock them in the Configuration Editor, or make the setting from IIS Manager.

### Caddy

Versions: Caddy 2.8 and later.

Generate the password hash with `caddy hash-password`, then in the `Caddyfile`:

```txt
staging.example.com {
    basic_auth {
        equipe REPLACE_WITH_THE_GENERATED_HASH
    }

    header X-Robots-Tag "noindex, nofollow"
    root * /var/www/staging/public
    file_server
}
```

In versions earlier than 2.8, the directive is written `basicauth`. Reload with `sudo systemctl reload caddy`.

### Cloudflare

Versions: Cloudflare One (Zero Trust), all plans including Free, November 2026.

Cloudflare Access places a login page in front of a host or a path, without touching the server. In the Zero Trust dashboard: `Access controls > Applications > Add an application > Self-hosted`. Enter the domain (`staging.example.com`) or the path (`example.com/intranet`), then create an “Allow” policy limited to your email addresses or your identity provider.

Two precautions: the origin must refuse connections that do not go through Cloudflare (firewall restricted to Cloudflare's ranges, or Cloudflare Tunnel), otherwise the server's IP address bypasses Access; and the host must be proxied (orange cloud).

### AWS

Versions: AWS console (Application Load Balancer, CloudFront, S3), November 2026.

- **Application Load Balancer and Cognito**: in the HTTPS listener rule, add the “Authenticate” action (Cognito user pool or OIDC provider) before the forward action, for private paths.
- **CloudFront, signed URLs and cookies**: in the [CloudFront console](https://console.aws.amazon.com/cloudfront/v4/home), open the relevant behavior and enable “Restrict viewer access” with a key group. Only URLs signed by your application, with a limited lifetime, are served. Suitable for private documents and media.
- **S3**: keep “Block all public access” enabled and serve the bucket through CloudFront with origin access control, or hand out short-lived presigned URLs.
- **Staging behind CloudFront**: a CloudFront function associated with the “viewer request” event adds Basic authentication.

```js
function handler(event) {
    var request = event.request;
    var expected = "Basic REPLACE_WITH_THE_BASE64_STRING";
    var header = request.headers.authorization;

    if (header && header.value === expected) {
        return request;
    }

    return {
        statusCode: 401,
        statusDescription: "Unauthorized",
        headers: {
            "www-authenticate": { value: 'Basic realm="Restricted access"' }
        }
    };
}
```

The string is obtained with `printf 'equipe:password' | base64`. Since the secret appears in the function's code, reserve this method for staging.

### Google Cloud

Versions: Identity-Aware Proxy, Google Cloud console, November 2026.

Identity-Aware Proxy protects a service behind a load balancer, App Engine or Cloud Run with a Google sign-in, with a list of authorized accounts. On Cloud Run, IAP can be enabled directly on the service, without a load balancer: the service's `Security` tab, “Require authentication” then “Identity-Aware Proxy (IAP)”, or `gcloud run services update SERVICE --region=REGION --iap`. Then grant the `roles/run.invoker` role to the project's IAP service agent.

### Azure

Versions: Azure App Service and Static Web Apps, Azure portal, November 2026.

On App Service, built-in authentication (`Settings > Authentication`) requires a sign-in through Microsoft Entra ID or another provider before reaching the application. On Static Web Apps, sign-in through GitHub or Microsoft Entra ID is available without configuration, but the restriction is declared in `staticwebapp.config.json`: a route rule with `"allowedRoles": ["authenticated"]` on private paths, and a redirect of the 401 response to `/.auth/login/aad`. The preconfigured Entra ID provider accepts any Microsoft account: to limit it to your organization, register a custom provider.

### Plesk

Versions: Plesk Obsidian 18.0.

`Websites & Domains > Password-Protected Directories > Add Protected Directory`. Enter `/` for the whole site or a subfolder, then create the users.

### cPanel

Versions: cPanel & WHM with the Jupiter theme, November 2026 versions.

`Files > Directory Privacy`: choose the folder, tick password protection, name the protected area, then create a user. cPanel writes the `.htaccess` file and the password file.

### Shared hosting

Without a dedicated tool, create a `.htaccess` file in the folder to protect. The `AuthUserFile` path must be absolute; the hosting provider gives it in its documentation.

```apache
AuthType Basic
AuthName "Restricted access"
AuthUserFile /home/compte/.htpasswd
Require valid-user
```

Generate the `.htpasswd` line with `htpasswd -n equipe` on your own computer, and place the file outside `public_html` or `www`.

### Vercel

Versions: Vercel dashboard, Hobby, Pro and Enterprise plans, November 2026.

[`Settings > Deployment Protection`](https://vercel.com/d?to=%2F%5Bteam%5D%2F%5Bproject%5D%2Fsettings%2Fdeployment-protection). “Vercel Authentication” restricts access to team members and, with the standard scope, protects preview deployments on all plans. Password protection is a paid option, and IP address restriction is reserved for the Enterprise plan; check the current pricing.

### Netlify

Versions: Netlify interface, credit-based plans and legacy plans, November 2026.

`Project configuration > General > Visitor access` offers password protection for the site or for non-production deployments, depending on the plan. On paid plans, Basic authentication can also be declared in the `_headers` file:

```txt
/intranet/*
  Basic-Auth: equipe:REPLACE_WITH_A_PASSWORD
```

Netlify states that this method is not suitable for sensitive data. The password also appears in clear text in a file versioned with the site.

### WordPress

Versions: WordPress 6.4 to 7.1.

- **Restricted pages**: a membership plugin or the “Private” status controls access to content, not to files.
- **Media Library files**: any file in `wp-content/uploads` is public if you know its URL. For private documents, use a plugin that stores them in a protected folder and serves them after a check, or store them outside the web root.
- **REST API**: private content is not exposed there, but check the routes added by plugins and the user list (`/wp-json/wp/v2/users`).
- **Per-post password**: light protection, not to be used for sensitive data.
- **Staging**: use the hosting provider's protection or server authentication, not just the “Discourage search engines from indexing this site” setting.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Private mode ([password page](https://help.shopify.com/en/manual/online-store/themes/password-page)), in `Online Store > Preferences`, “Store access” section, protects the whole store before launch. For restricted content, rely on customer accounts and the access conditions of the theme or an app; files uploaded to `Content > Files` remain public through their URL.

### Laravel

Versions: Laravel 10 to 13. The `local` disk points to `storage/app/private` since Laravel 11, to `storage/app` on Laravel 10.

Group private routes behind the `auth` middleware and check resource ownership with a policy:

```php
Route::middleware('auth')->group(function () {
    Route::get('/espace-client', [AccountController::class, 'show'])->name('account');

    Route::get('/factures/{invoice}', [InvoicesController::class, 'show'])
        ->name('invoice')
        ->can('view', 'invoice');
});
```

Store private files on a non-public disk (`storage/app/private`), never in `storage/app/public`, and serve them through a controller or a time-limited signed link:

```php
$url = URL::temporarySignedRoute('invoiceDownload', now()->addMinutes(30), [
    'invoice' => $invoice,
]);
```

The corresponding route carries the `auth` and `signed` middleware. For staging, prefer web server authentication: it also protects static files.

### Next.js

Versions: Next.js 15 and 16 (App Router and Pages Router).

Check the session on the server side, in the proxy (`proxy.ts` since Next.js 16, `middleware.ts` up to Next.js 15) and in every server component, API route or Server Action that returns or modifies private data. Next.js recommends not relying on the proxy alone: a modified `matcher` can remove a route's protection without anything breaking. A check done only in the browser leaves the data accessible through the API.

## Common mistakes

- **Listing private areas in robots.txt**: you point them out to everyone without protecting them.
- **Relying on `noindex`**: the page can still be downloaded.
- **Protecting the page but not the file**: the linked PDF remains accessible through its direct URL.
- **Leaving staging open** “for the duration of the tests”.
- **Letting “Googlebot” through an authentication wall on the strength of the user agent**: anyone can spoof it.
- **Responding with a 200 and a login form** instead of the content: the search engine indexes empty pages, and you no longer see denied access in the logs.
- **Letting a CDN cache an authenticated response**: one user's content is served to the next.
- **Putting the staging password in the code repository** or sharing it in an open channel.
- **Forgetting the origin behind an access service**: if the server's IP address responds directly, the protection can be bypassed.

## Frequently asked questions

### Does robots.txt protect a private page?

No, robots.txt protects no page. It is a public instruction that crawlers choose to follow, and listing sensitive paths in it amounts to pointing them out. User-triggered fetchers such as ChatGPT-User or Perplexity-User may not even apply it when a user gives them a URL. Only server-side authentication prevents a crawler or a stranger from reading the content.

### Does the noindex tag prevent ChatGPT from reading my page?

No, `noindex` only asks a search engine not to show the page in its results. It does not prevent anyone from downloading it, and it says nothing to crawlers that do not build a search index: an AI assistant given the URL can read the page. For private content, require authentication that returns a 401, a 403 or a redirect to the login page.

### How do I protect a staging site from crawlers?

Protect the whole staging host with server-side authentication: HTTP Basic authentication on Apache, Nginx or Caddy, the hosting provider's protection, Cloudflare Access or Vercel's Deployment Protection. The WordPress setting that asks search engines not to index the site is not enough. Then check that an anonymous request receives a 401 or a 403, and never commit the password to version control.

### Are the PDF files in a customer area protected along with the page?

Not necessarily: a protected page can link to files accessible through their direct URL. On WordPress, any file in `wp-content/uploads` is public as soon as someone knows its address. Store private documents outside the web root and serve them through the application after a check, or through a time-limited signed link. Then test each file with an anonymous request.

## Resources

- [Google: robots.txt is not a mechanism for keeping a page out of Google](https://developers.google.com/search/docs/crawling-indexing/robots/intro)
- [Google: block indexing with noindex](https://developers.google.com/search/docs/crawling-indexing/block-indexing)
- [OpenAI: crawlers and user agents, including ChatGPT-User](https://developers.openai.com/api/docs/bots)
- [Perplexity: crawlers, including Perplexity-User](https://docs.perplexity.ai/docs/resources/perplexity-crawlers)
- [Anthropic: Claude's crawlers](https://support.claude.com/en/articles/8896518)
- [Bing Webmaster Tools](https://www.bing.com/webmasters/)
- [MDN: HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Authentication)
- [Apache: authentication and authorization](https://httpd.apache.org/docs/2.4/howto/auth.html)
- [Nginx: auth_basic module](https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html)
- [Caddy: basic_auth directive](https://caddyserver.com/docs/caddyfile/directives/basic_auth)
- [Cloudflare Access: self-hosted applications](https://developers.cloudflare.com/cloudflare-one/applications/configure-apps/self-hosted-public-app/)
- [Amazon CloudFront: private content, signed URLs and signed cookies](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html)
- [Netlify: Basic authentication with custom HTTP headers](https://docs.netlify.com/manage/security/secure-access-to-sites/basic-authentication-with-custom-http-headers/)
- [Laravel: authentication](https://laravel.com/docs/authentication) and [signed URLs](https://laravel.com/docs/urls#signed-urls)

Next steps: [make public pages accessible without logging in](https://checklist-seo-geo.com/en/ai-crawler-access-data-policy/make-public-pages-accessible-without-logging) and [protect private information with access control](https://checklist-seo-geo.com/en/security-infrastructure/protect-private-information-access-control).
