+ +

Guide · Updated October 10, 2026 · 7 min read

How to password protect a web page

Whether it is one page you need to send to a client or a whole website, there are four common ways to put a password on it, and one of them isn’t protection at all. Here’s the honest ranking: what each option guards against, what it takes to set up, and how to pick.
+ +

The short answer

To password protect a web page, or a whole website, the password check must happen on the server, before any content is sent to the browser. You can do this with server configuration (like .htaccess on Apache), with your hosting platform’s built-in protection, or with a publishing service such as Pagelive that enforces a hashed password at the edge. JavaScript-only prompts don’t qualify: the page has already been delivered.

+ +

The options, ranked

Four ways to password protect a page, ranked honestly

The test that separates them: does the password check run before the page is served, or after it’s already in the visitor’s browser?
Option 1 Real protection · most setup

Server configuration (.htaccess / basic auth)

On a server you control, you can require a password before the server responds at all: .htaccess plus .htpasswd on Apache, auth_basic on nginx. It’s genuine protection because the check happens before any content leaves the server. The trade-offs: you need server access and config skills, the browser shows a bare system prompt rather than a branded page, it usually protects a whole directory rather than a single page, and it doesn’t exist at all on most static or drag-and-drop hosts.

Option 2 Real protection · if server-enforced

Your hosting platform’s built-in protection

Some hosting platforms offer password protection as a feature. When the platform enforces the check on its servers before serving the page, this is real protection. Two things to verify: that the gate runs server-side (not a script in the page, see option 4), and what it covers. It’s often site-wide rather than per-page, and frequently reserved for higher-priced tiers.

Option 3 Real protection · least setup

A publishing service with an edge-enforced gate

Services built for sharing private pages enforce the password at the edge: the request is stopped at the CDN, before the page is served, with no server of your own to configure. On Pagelive you set a password per page when you publish (or any time after); it’s hashed before storage, so we can’t see it, and the page is also kept out of search by default. Setup is the time it takes to type the password.

Option 4 Not protection

JavaScript-only “protection”

Tutorials abound for a password prompt written in JavaScript: the page loads, a script asks for a password, and shows the content if it matches. The problem is the order of events: by the time the script runs, the full page has already been delivered to the browser. Anyone can read it with View Source or by turning JavaScript off, the password itself often sits in the page code, and search engines can index the content behind the prompt. It’s a curtain, not a lock: fine for a playful easter egg, never for anything confidential.

+ +

Worth understanding

Why a JavaScript prompt isn’t a lock

It’s worth being precise about this, because the JavaScript approach looks identical to the real thing from the visitor’s side. The difference is invisible but decisive: with a server-side or edge-enforced gate, the server refuses to send the page until the password checks out. With a JavaScript prompt, the server has already sent everything: the script just hides it. Hidden is not protected. View Source shows the content, disabling JavaScript shows the content, and a crawler that ignores scripts reads the content. None of this requires any skill; it’s a right-click.

So the rule of thumb: if you could not comfortably email the page to a stranger, don’t rely on a script to guard it.

+ +

The fastest real option

Password protect a page in three steps, no server

If you don’t run your own server (or don’t want to), this is the whole process on Pagelive. Passwords come with Solo and Team. Start your 10-day trial, cancel anytime.
1

Publish the page

Upload the file at app.pagelive.io, or say “publish this” in Claude. You get a live link in seconds. No server, no config.

2

Set the password

Add a password at publish time or later from the page’s settings. It’s hashed (PBKDF2) the moment you save it: nobody at Pagelive can read it.

3

Share the link

Send the link, and the password separately if you like. The gate is enforced at the edge before any content is served, and your view tracking keeps working.

A page asking the visitor for their email, and the Access panel with password and verified email

The full feature (what the gate looks like to your recipient, changing or removing the password, what happens if it’s forgotten) is on the password-protected pages page. And the password is one layer of several: here’s how Pagelive keeps pages private end to end (noindex by default, content served separately from your account, on SOC 2 Type II-ready infrastructure on Cloudflare).

+ +

Frequently asked

Use a publishing service that enforces the password before the page is served. With Pagelive you upload your HTML, set a password, and share the link. The check runs at the edge, the password is hashed, and the page stays out of search by default. No server, no .htaccess, no code.

Want the one-switch version? See password protected pages on Pagelive. Related guides: how to share an HTML file as a link · share a Claude artifact without a login. Sending client proposals? See AI proposal software. More in the guides library.

+ +

Put a real lock on your next page.

Edge-enforced password, hashed so we can’t see it, kept off Google by default. Passwords are on Solo and Team. Start your 10-day trial, cancel anytime.