# Nitro Sites — Apache / LiteSpeed safe rules for static + contact.php deploy.
# Tested against Apache 2.4 (Ubuntu) with AllowOverride All.
# === Block sensitive paths ===
RedirectMatch 404 /\.rate-limit(/.*)?$
Require all denied
# === Error pages ===
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
# === MIME types LiteSpeed does not map on this host (without these, .webp
# ships with NO Content-Type and ExpiresByType image/webp never matches) ===
AddType image/webp .webp
AddType image/avif .avif
# === Sensible caching by file type ===
ExpiresActive On
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType image/svg+xml "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/webp "access plus 30 days"
ExpiresByType image/avif "access plus 30 days"
ExpiresByType image/x-icon "access plus 30 days"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
# === HTML: revalidate every visit so deploys are seen immediately ===
Header set Cache-Control "public, max-age=0, must-revalidate"
# Hashed bundles in /_astro/ are content-addressed — long immutable cache.
# Matches Astro's hashed filename pattern: name.HASH.ext
Header set Cache-Control "public, max-age=31536000, immutable"
# === Compression (Apache mod_deflate) ===
AddOutputFilterByType DEFLATE text/html text/css application/javascript image/svg+xml application/json text/xml text/plain
# === HTTPS upgrade (M5) ===
# Cloudflare proxies this site, so the ORIGINAL scheme arrives in X-Forwarded-Proto.
# Redirect when the visitor's request was plain http — loop-safe under any Cloudflare
# SSL mode (Flexible sends XFP=https for https visitors even though the origin hop is
# http). The second condition covers direct-to-origin requests with no XFP header
# ("" + "off" = "off"). MUST run before the file/dir passthrough below, which is [L].
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
RewriteCond %{HTTP:X-Forwarded-Proto}%{HTTPS} =off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# HSTS — only on responses whose original request was https (via XFP), so a
# Flexible-SSL http origin hop never emits it on a plain-http response.
# Host-only (no includeSubDomains — em.* and friends are third-party CNAMEs).
SetEnvIf X-Forwarded-Proto https NITRO_HTTPS=1
Header always set Strict-Transport-Security "max-age=31536000" env=NITRO_HTTPS
# === Security response headers (2026-07-14) ===
# Set on every response. Safe for this site: nothing frames itself cross-origin,
# and no page uses the browser geolocation/camera/microphone APIs (verified).
# A Content-Security-Policy is deliberately NOT set here yet: the site loads inline
# GTM + reCAPTCHA and several third-party origins, so a real CSP must be built in
# Report-Only and tuned before enforcing (tracked separately) rather than bolted on.
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Permissions-Policy "geolocation=(), camera=(), microphone=()"
# === Moved pages ===
# Network Status moved under the tools banner (2026-07-14). Real 301 for SEO;
# a static meta-refresh page at /network/ backs this up on any host.
# Written as a RewriteRule, not mod_alias Redirect: the alias form appended the
# trailing-slash rule's "/" to the target and Google recorded
# /tools/network-status// (found in the 18 Sep sitemap check).
RewriteEngine On
RewriteRule ^network/?$ /tools/network-status/ [R=301,L]
# Booking page owner renamed 23 Aug 2026: no staff name in a public URL.
RedirectMatch 301 ^/book/rick/?$ /book/call/
# === Canonical host: www redirects to the apex (2026-09-17) ===
# www.nitrosites.com serves a duplicate 200 of every page on the site, and Search
# Console lists www URLs as referrers (found 17 Sep 2026), so Google sees two copies
# of everything. One 301 collapses them onto the apex.
# Loop-safe: the target host has no "www." prefix, so the condition cannot match the
# redirected request. The substitution contains no "?", so Apache appends the original
# query string automatically. Placed ABOVE the renamed-funnel rules and the
# add-a-trailing-slash rule so the host is fixed in a single hop.
RewriteEngine On
# An extensionless www URL with no trailing slash gets the slash in the SAME
# hop, so http://www.x/tools is edge https, then apex + slash: two hops, not
# three (the third was the Search Console "Redirect error").
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{REQUEST_URI} !\.[a-zA-Z0-9]+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^ https://nitrosites.com%{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://nitrosites.com%{REQUEST_URI} [R=301,L]
# === Old-site URLs: one clean answer each (2026-09-18) ===
# Every line comes from the Search Console Page indexing export
# (docs/SEO-INDEXING-CLEANUP-2026-09.md). 301 where the content lives on
# somewhere, 410 (Gone) where it never will, so Google drops the URL instead of
# re-crawling a 404 for years. Placed ABOVE the add-a-trailing-slash rule so none
# of these bounce through a 301 into a 404.
RewriteEngine On
# Old WordPress home, legal pages, feed, cart, sitemap
RewriteRule ^home/?$ / [R=301,L]
RewriteRule ^terms-of-service/?$ /terms/ [R=301,L]
RewriteRule ^privacy-policy/?$ /privacy/ [R=301,L]
RewriteRule ^feed/?$ /rss.xml [R=301,L]
RewriteRule ^cart/?$ /pricing/ [R=301,L]
RewriteRule ^page-sitemap\.xml$ /sitemap-index.xml [R=301,L]
# NitroReel was renamed NitroScreenShow (24 Nov 2026).
RewriteRule ^products/nitroreel(/.*)?$ /products/nitroscreenshow/ [R=301,L]
# Articles that moved from /blog/ into the hubs
RewriteRule ^blog/what-is-a-docker-container/?$ /learn/what-is-a-docker-container/ [R=301,L]
RewriteRule ^blog/what-is-google-tag-manager/?$ /learn/what-is-google-tag-manager/ [R=301,L]
RewriteRule ^blog/tag-guide/?$ /learn/what-is-google-tag-manager/ [R=301,L]
RewriteRule ^blog/how-to-add-a-domain-administrator-in-cloudflare/?$ /kb/how-to-add-a-domain-administrator-in-cloudflare/ [R=301,L]
RewriteRule ^blog/site-suspended-non-payment/?$ /kb/site-suspended-non-payment/ [R=301,L]
RewriteRule ^blog/how-to-make-a-payment/?$ /kb/how-to-make-a-payment/ [R=301,L]
RewriteRule ^blog/google-zero-click-search-2026/?$ /news/google-zero-click-search-2026/ [R=301,L]
# Any other article that moved off /blog/ (21 Nov 2026): Googlebot was spending
# a fifth of its visits on ~32 old /blog// 404s fed by the blog RSS and
# image sitemap. Redirect to whichever hub now holds that slug, found on disk,
# so a future move needs no new line here. A real /blog/ post still wins.
RewriteCond %{DOCUMENT_ROOT}/blog/$1/index.html !-f
RewriteCond %{DOCUMENT_ROOT}/learn/$1/index.html -f
RewriteRule ^blog/([a-z0-9-]+)/?$ /learn/$1/ [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/blog/$1/index.html !-f
RewriteCond %{DOCUMENT_ROOT}/kb/$1/index.html -f
RewriteRule ^blog/([a-z0-9-]+)/?$ /kb/$1/ [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/blog/$1/index.html !-f
RewriteCond %{DOCUMENT_ROOT}/news/$1/index.html -f
RewriteRule ^blog/([a-z0-9-]+)/?$ /news/$1/ [R=301,L]
# Tag Explorer's "Learn more" links pointed at /blog/tag-guide// for a
# year without those pages existing; the 23 guides now live on /learn
# (docs/TAG-GUIDE-REDIRECTS.md). One slug changed, so it goes first.
RewriteRule ^blog/tag-guide/google-tag-manager/?$ /learn/gtm-container-explained/ [R=301,L]
RewriteRule ^blog/tag-guide/([a-z0-9-]+)/?$ /learn/$1/ [R=301,L]
# Unfinished build artefact that duplicated the KB article (deleted 2026-09-18)
RewriteRule ^learn/cloudflare-access-guide/?$ /kb/how-to-add-a-domain-administrator-in-cloudflare/ [R=301,L]
# Gone for good: old posts with no successor, WordPress and DotNetNuke leftovers,
# and a phone number that was once pasted into a link and crawled as a path
RewriteRule ^(the-future-of-web-design-trends-to-watch-in-2025|mastering-seo-in-2025-what-works-now|the-role-of-ai-in-web-development-how-its-changing-the-game|laravel-vs-wordpress-which-one-should-you-choose|langs|sample-page)(/.*)?$ - [G,L]
RewriteRule ^(wp-admin|wp-includes|wp-content|wp-json|wp-login\.php|xmlrpc\.php)(/.*)?$ - [G,L]
RewriteRule ^SiteMap/tabid(/.*)?$ - [G,L]
# Previous owners of this domain (10 Oct 2026): a gambling site in 2023 and 2024
# and a shop and florist on subdomains. Gone, so Google forgets them faster.
RewriteRule ^(wanboguanwangmanbetx|collections|floral-journal|qrCode\.jsp)(/.*)?$ - [G,L]
RewriteRule ^(blog/|privacy-policy/)?0395262015/?$ - [G,L]
# The tool scan endpoints are APIs, not pages: keep them out of the index.
Header set X-Robots-Tag "noindex"
# === Renamed funnel landing URLs (2026-08-22) - PERMANENT, DO NOT REMOVE ===
#
# Two live lead funnels lost their hyphen on 22 Aug 2026:
# /chatgpt-ads -> /chatgptads
# /free-website -> /freewebsite
#
# Why these two redirects are load bearing, not tidy-up:
# * The ChatGPT Ads campaign LAUNCHED on 22 Aug 2026 with its landing URL set
# to the hyphenated /chatgpt-ads. Ads Manager, the ad copy, the emails
# already sent and the social creatives all carry that URL. Deleting this
# line sends every click of live paid spend to a 404.
# * /free-website has been publicly linked and indexed since June 2026 and is
# the landing page for the White Knight outreach campaign. Mail already in
# people's inboxes points at it and cannot be recalled.
# Treat both as permanent. There is no future date at which removing them is
# safe, because we cannot un-send an email or un-print a URL.
#
# Written as RewriteRules rather than mod_alias "Redirect" ON PURPOSE. Read this
# before "simplifying" it back:
# 1. In .htaccess context mod_rewrite's fixup hook is registered APR_HOOK_FIRST
# and mod_alias's is APR_HOOK_MIDDLE, so mod_rewrite ALWAYS runs first no
# matter which directive appears earlier in the file. A plain
# "Redirect 301 /chatgpt-ads /chatgptads/" would therefore lose the race to
# the generic add-a-trailing-slash RewriteRule directly below: /chatgpt-ads
# would first 301 to /chatgpt-ads/, and only then would mod_alias fire,
# appending the leftover "/" to the target and emitting /chatgptads// .
# That is two hops and a malformed URL.
# 2. These rules sit ABOVE that trailing-slash rule in the same engine and in
# the same per-directory context, so they are evaluated first on Apache and
# on LiteSpeed alike (rules merge in file order within one context).
# 3. Each pattern matches the old path with OR without a trailing slash and
# ends in [L], so every old URL is exactly ONE hop to the new one. A loop is
# impossible: the targets (/chatgptads/, /freewebsite/) do not match the
# patterns (^chatgpt-ads/?$, ^free-website/?$).
# 4. QUERY STRINGS SURVIVE. A RewriteRule whose substitution contains no "?"
# passes %{QUERY_STRING} through untouched, so ?utm_source/?utm_medium/
# ?utm_campaign and the A/B split parameters ?v=a and ?v=b all reach the new
# page intact. That is essential: without it every ad click would land with
# no attribution and the A/B test would silently collapse to one variant.
# (mod_alias Redirect preserves the query string too, so this is not the
# reason for choosing RewriteRule; hop count is.)
#
# VERIFIED, not reasoned: both forms were run against a real Apache 2.4.68 with
# this exact .htaccess on 22 Aug 2026. With the rules below, /chatgpt-ads,
# /chatgpt-ads/, /free-website and /free-website/ each returned a single 301 to
# the new URL with the query string intact. With the naive mod_alias form,
# /chatgpt-ads returned 301 -> /chatgpt-ads/ -> 301 -> /chatgptads// (two hops,
# double slash), exactly as described above.
#
# Note the trailing slash on the targets: it points straight at the directory
# index Astro builds (/chatgptads/index.html), so the trailing-slash rule below
# never needs to fire for these and cannot add a second hop.
RewriteEngine On
RewriteRule ^chatgpt-ads/?$ /chatgptads/ [R=301,L]
# 21 Nov 2026: one address for ChatGPT Ads. The old service page moved here.
RewriteRule ^services/chatgpt-ads/?$ /chatgptads/ [R=301,L]
RewriteRule ^free-website/?$ /freewebsite/ [R=301,L]
# === Pretty URL routing ===
# Astro builds /about/index.html — Apache serves /about/ natively via DirectoryIndex.
# Add a fallback so /about (no slash) → /about/ (so links don't 404).
RewriteEngine On
# Reserved funnel addresses: /f/ is one static page serving every
# client. The slug is NOT a directory on disk, so this has to run BEFORE the
# add-a-trailing-slash rule below, which would otherwise 301 it into a 404.
# Internal rewrite (no R flag) so the slug survives in the address bar for
# the page's own script to read.
# EXCEPT: a slug that IS a real directory under /f/ is a custom-built funnel
# (e.g. /f/meowsprout) and gets served as ordinary static files instead of
# the generic spec renderer.
RewriteCond %{DOCUMENT_ROOT}/f/$1 !-d
RewriteRule ^f/([a-z0-9-]{3,60})/?$ /f/index.html [L]
# If request maps to a real file or directory, serve it.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Otherwise, if the URI has no extension and no trailing slash,
# redirect to // so Apache picks up the index.html inside.
RewriteCond %{REQUEST_URI} !\.[a-zA-Z0-9]+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ /$1/ [L,R=301]