Every Cloud Platform environment is provisioned with a default subdomain that ends in .acquia-sites.com, for example, mysite.prod.acquia-sites.com. You cannot remove or replace this default domain. It persists even after you configure a custom domain and point DNS to your environment.
When you protect your site with a CDN or Web Application Firewall (WAF), such as Acquia Edge powered by Cloudflare, Fastly, or Akamai, on your custom domain, the Acquia default domain can still be publicly accessible. Therefore, an attacker who discovers your default domain can send requests directly to your origin server and bypass your CDN or WAF security rules entirely. These rules include rate limits, bot protection, IP blocklists, and DDoS mitigation.
Use the .htaccess rules in this article to restrict access to the Acquia default domain so that only trusted parties, such as the customer and Acquia Support, can access it.
Use these rules when all of the following are true:
www.example.com, for production traffic.mysite.prod.acquia-sites.com, to bypass your CDN or WAF.If your site does not use a CDN or WAF, adopt Acquia Edge instead. Acquia Edge provides edge-level protection before traffic reaches your origin server.
Before you implement these rules, ensure the following:
.htaccess.On Cloud Platform, all incoming traffic passes through Elastic Load Balancers (ELBs) and Varnish reverse proxy caches before it reaches the Apache web server. Therefore, the standard Apache variable REMOTE_ADDR always returns the internal IP address of the load balancer instead of the actual client IP address.
To match the real client IP in .htaccess rules, you must use the AH_Client_IP variable. Acquia infrastructure sets this variable, and it always reflects the original client IP. Use the correct syntax for the type of rule that you create:
RewriteCond rules: %{ENV:AH_Client_IP}SetEnvIf directives: AH_CLIENT_IPDo not use %{REMOTE_ADDR} or X-Forwarded-For for IP-based access controls on Acquia Cloud. These do not produce reliable results due to the load balancer and ELB architecture.
This option redirects all requests that arrive on the Acquia default domain to your custom domain with a 301 permanent redirect. The redirect sends visitors and bots that discover your default domain to your production site.
Add the following rules to your .htaccess file, replacing mysite.prod.acquia-sites.com with your actual Acquia default domain and www.example.com with your custom domain:
# Redirect Acquia default domain to custom domain
RewriteCond %{HTTP_HOST} ^mysite\.prod\.acquia-sites\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]Line-by-line explanation:
| Line | Purpose |
|---|---|
RewriteCond %{HTTP_HOST} ^mysite\.prod\.acquia-sites\.com$ [NC] | Matches requests where the Host header is exactly your Acquia default domain (case-insensitive). |
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] | Redirects the full request path to your custom domain with a 301 (permanent) redirect. The L flag stops further rule processing. |
This option returns a 403 Forbidden response to any request on the Acquia default domain that does not come from an allowlisted IP address. Only the IP addresses you specify, such as your office IP and the Acquia Support IP, can access the default domain.
Add the following rules to your .htaccess file, replacing the example IP addresses with your actual trusted IPs:
# Return 403 on Acquia default domain, except for allowlisted IPs
<IfModule mod_setenvif.c>
# Match requests on the Acquia default domain
SetEnvIf Host mysite\.prod\.acquia-sites\.com AcquiaDomain=1
# Allowlist your customer IP address
SetEnvIf AH_CLIENT_IP ^203\.0\.113\.10$ AllowedIP=1
# Allowlist Acquia Support IP range (obtain from Acquia Support)
SetEnvIf AH_CLIENT_IP ^198\.51\.100\. AllowedIP=1
</IfModule>
<IfModule mod_authz_core.c>
<If "-n %{ENV:AcquiaDomain} && -z %{ENV:AllowedIP}">
Require all denied
</If>
</IfModule>Line-by-line explanation:
| Line | Purpose |
|---|---|
SetEnvIf Host mysite\.prod\.acquia-sites\.com AcquiaDomain=1 | Sets the AcquiaDomain environment variable when the request Host header matches the Acquia default domain. |
SetEnvIf AH_CLIENT_IP ^203\.0\.113\.10$ AllowedIP=1 | Sets the AllowedIP environment variable when the client IP is an exact match for an allowlisted address. |
SetEnvIf AH_CLIENT_IP ^198\.51\.100\. AllowedIP=1 | Sets AllowedIP for an entire IP range, which is a subnet prefix match. Add one line per trusted IP or range. |
<If "-n %{ENV:AcquiaDomain} && -z %{ENV:AllowedIP}"> | Applies the Require all denied directive only when the request is on the default domain AND the client IP is not allowlisted. |
Require all denied | Returns a 403 Forbidden response. |
The IP addresses 203.0.113.10 and 198.51.100.x in the previous example are documentation examples from the RFC 5737 reserved ranges and are not real IP addresses. Replace them with your actual trusted IP addresses before you deploy the rules.
Insert these rules in your .htaccess file after the RewriteEngine On directive and before any other redirect or rewrite rules. Placing them early ensures the rules are evaluated first.
RewriteEngine On
# --- Acquia default domain restriction (add here) ---
RewriteCond %{HTTP_HOST} ^mysite\.prod\.acquia-sites\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# ---------------------------------------------------
# Your other redirect rules follow here
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]Test your .htaccess changes in a non-production environment, such as dev or staging before deploying to production. An error in .htaccess can make your site inaccessible.
After deploying your .htaccess changes, use curl to verify that the rules are working correctly.
Test Option A (301 redirect):
curl -I http://mysite.prod.acquia-sites.com/Expected response: HTTP/1.1 301 Moved Permanently with a Location header pointing to your custom domain.
Test Option B (403 Forbidden from a non-allowlisted IP):
curl -I http://mysite.prod.acquia-sites.com/Expected response: HTTP/1.1 403 Forbidden
To verify that an allowlisted IP receives a normal response, use a machine or VPN connection with the allowlisted IP and repeat the curl command. You must receive a 200 OK response.
If you want to implement Option B, an IP allowlist, to restrict your Acquia default domain, you must contact Acquia Support to obtain the IP address or IP range that Acquia Support engineers use. This requirement ensures that Acquia Support can continue to access your environment through the default domain to test, troubleshoot, and maintain the platform.
To request the Acquia Support IP:
.htaccess IP allowlisting on your Acquia default domain.If you implement Option B, you must add the Acquia Support IP address to the allowlist. Otherwise, Acquia Support engineers cannot access your environment to troubleshoot or respond to incidents.
AI-Generated Draft
To help publish information faster, this documentation uses AI-assisted drafting alongside human technical review. If you spot an inaccuracy or need to verify a critical implementation, please contact your Acquia representative or Acquia Support directly.