Security

Joomla staging sites: keep Google and visitors out

Joomla staging sites: keep Google and visitors out

Close a Joomla staging site with Site Offline (503), an IP or password rule in .htaccess, or IP Access. noindex alone keeps out neither people nor Google.

A staging copy of a Joomla site has two kinds of unwanted visitors: people who find it by accident, and search engines that index it next to the real site. A noindex tag alone stops neither of them in time. What works is a real lock on the door, with a status code that tells crawlers to come back later. You can set that up by hand with Joomla and your server, or let our own IP Access module do it from the administrator.

Option 1: Site Offline, the lock Joomla already has

Go to System > Global Configuration > Site and set Site Offline to Yes. Visitors get the offline page of your template with a login form, and Joomla sends it with the status 503 Service Temporarily Unavailable. That is the right signal for Google: the site is temporarily closed, do not index this, try again later.

  • Pick Use Custom Message and write one line, such as "This site is being built." Add an Offline Image if you like.
  • You and the client log in on that offline page. Only user groups with the Offline Access permission get past it. By default that is Super Users only; how to give a client group that right is in allowing offline access for other users.
  • The administrator stays reachable at /administrator.

The weak spots: anyone you want to show the site needs a Joomla account, and files in images/ and media/ are served by the web server directly, so a direct link to a PDF still works. If the System - Page Cache plugin is on, it can hand out a stored page before the offline check runs. Switch that plugin off on staging.

Option 2: lock it on the server

A block in .htaccess stops every request before Joomla starts, including images, PDFs and the administrator. On Apache 2.4 (most shared hosting), put this at the top of the .htaccess in the staging folder:

<RequireAny>
  Require ip 203.0.113.7
  Require ip 198.51.100.0/24
</RequireAny>

Everyone else gets a 403. If addresses change too often for a list, use a password instead. Create the file with htpasswd -c /home/user/.htpasswd-staging client (outside the web root) and add:

AuthType Basic
AuthName "Staging"
AuthUserFile /home/user/.htpasswd-staging
Require valid-user

Crawlers then get a 401 and never see a page. Two things to watch. Behind Cloudflare or another CDN, Apache sees the address of the proxy, not the visitor, so Require ip blocks or allows the wrong people unless the host has set up mod_remoteip. And the lock also covers api/ and the update check from Joomla itself, which is usually what you want on staging.

Like Site Offline, IP Access protects pages, not files: the administrator and the images/ folder are outside its reach. For the administrator login, a server rule or our Admin Protect module is the tool.

Why noindex and robots.txt are not enough

Setting Robots to noindex, nofollow under Global Configuration > Site > Metadata only asks search engines not to list a page. The page is still open to anyone with the link. Worse, if you also put Disallow: / in robots.txt, Google can no longer fetch the page and never sees the noindex, so the bare address can still show up in results. The details are in robots.txt in Joomla: what to block and what blocking cannot do. Use noindex as an extra layer on top of a real lock, not as the lock. A server-wide version is Header set X-Robots-Tag "noindex, nofollow" in .htaccess, which also covers PDFs and images.

A staging copy also talks to the outside world

A copy of a live site still sends mail, runs scheduled tasks and loads tracking code. Before you share the staging address:

  • Set Send Mail to No under Global Configuration > Server > Mail, or form submissions and password resets go to real customers.
  • Disable tasks under System > Scheduled Tasks that send newsletters, sync with other systems or clean up data.
  • Remove or swap Google Analytics and tag manager codes, so test clicks do not end up in the live statistics.
  • Put payment and shipping extensions in test mode.

Checklist before staging goes live

  • Site Offline back to No, or the IP Access module unpublished.
  • The Require ip or AuthType Basic lines removed from .htaccess.
  • Robots in Global Configuration back to index, follow, and no Disallow: / left in robots.txt.
  • Send Mail back on, scheduled tasks enabled, live tracking codes and payment keys in place.
  • Open the live site in a private window and check the status with curl -I https://example.com/: it should say 200, not 401, 403 or 503.
Stuck on something else?

Doctor Joomla is a project of Cloudfaction, a Dutch agency building and maintaining Joomla sites since 1999. The articles are made with the help of AI, so tell us if something does not match your screen. Mail info@cloudfaction.nl if you want someone to look at yours.

Rather have someone look at it

Doctor Joomla is a Cloudfaction project.

A Dutch agency that has been building and running Joomla sites since 1999. If your site needs more than an article can fix, get in touch.