ThisCalculator

Everyday

Mask a Domain in WordPress: Redirects, DNS, Iframes

Updated · Standard formula, shown below

Mask a Domain in WordPress: Redirects, DNS, Iframes

Masking a domain in WordPress lets you show one domain in the browser’s address bar while the actual content is served from another. This is commonly used when you want a clean, branded URL for a site hosted elsewhere, or when you need to keep the backend URL hidden. The technique involves three separate parts: DNS records, a redirect (often a reverse proxy or iframe), and WordPress settings. Before you start, you need access to your domain registrar’s DNS panel, your hosting control panel (for SSL certificates), and WordPress admin.

What You’ll Need

  • Access to your domain registrar (e.g., GoDaddy, Namecheap, Cloudflare) to edit DNS records.
  • Access to your WordPress hosting control panel (cPanel, Plesk, or a cloud server) to set up a reverse proxy or iframe.
  • An SSL certificate for both the original and the masking domain (most hosts offer free Let’s Encrypt).
  • Basic familiarity with editing files via FTP or the WordPress admin file manager.

Step-by-Step

  1. Decide on the masking method. There are two main ways: a reverse proxy (recommended for full control and SEO) or an iframe (simpler but with limitations). This guide covers both, starting with the reverse proxy.
  2. Set up DNS for the new domain. Log into your registrar and create an A record for the domain you want to mask (e.g., www.newdomain.com) pointing to the IP address of the server where your WordPress site is hosted. If you’re using a CDN or a service like Cloudflare, you may use a CNAME record instead. Wait for DNS propagation (can take up to 48 hours, but often less).
  3. Install an SSL certificate on the new domain. In your hosting control panel, add the new domain as an addon domain or a separate site, then issue a free SSL certificate (Let’s Encrypt) for it. This is required so the masked URL shows a padlock.
  4. Set up a reverse proxy (Apache example). If you’re using Apache, create a virtual host configuration for the new domain. Use the ProxyPass and ProxyPassReverse directives to forward all requests to your WordPress site’s URL. For example:
    ProxyPass / http://your-wordpress-site.com/
    ProxyPassReverse / http://your-wordpress-site.com/

    Enable the proxy modules (mod_proxy, mod_proxy_http) and restart Apache.

  5. Set up a reverse proxy (Nginx example). In your Nginx server block, add a location / block with proxy_pass http://your-wordpress-site.com; and set the Host header to the original site’s domain to avoid redirect loops. Also set proxy_set_header X-Forwarded-For and X-Forwarded-Proto.
  6. If you prefer an iframe method instead: Create a simple HTML page on the new domain that contains an iframe with the full URL of your WordPress site. For example:
    <iframe src="https://your-wordpress-site.com" width="100%" height="100%" style="border:none;"></iframe>

    Upload this as index.html in the new domain’s web root. Note that iframes can break links, forms, and responsive design.

  7. Update WordPress to use the new domain (only for reverse proxy). If you’re using a reverse proxy, WordPress needs to know the new domain. Install a plugin like “WordPress Address Change� or manually edit wp-config.php to add:
    define('WP_HOME','https://www.newdomain.com');
    define('WP_SITEURL','https://www.newdomain.com');

    Alternatively, use the built-in “Settings > General� to change the WordPress Address and Site Address, but only do this after the proxy is working to avoid lockout.

  8. Handle internal links and assets. After changing the site URL, WordPress will generate links with the new domain. For existing content, use a search-replace plugin to update any hardcoded old URLs in the database.
  9. Force HTTPS and redirects. Add a redirect rule so that any request to the original domain redirects to the new masked domain (if that’s desired). In .htaccess (Apache) or server config, add a 301 redirect for the old domain.
  10. Test thoroughly. Visit the new domain in a private browser window. Check the URL bar, SSL padlock, internal navigation, forms, and any AJAX functionality. Ensure the WordPress admin is accessible (maybe via the original domain or a subdomain).

Common Mistakes

  • DNS not propagated: Changing A records but not waiting or using the wrong IP can cause the new domain to point nowhere.
  • SSL certificate mismatch: If the new domain’s certificate doesn’t cover it, browsers will show a security warning.
  • Redirect loops: When the proxy forwards to the original domain, and the original domain redirects back to the new domain, you get infinite redirects. Set the Host header correctly and avoid redirects on the original site.
  • Iframe issues: Many sites send an X-Frame-Options: SAMEORIGIN header that blocks iframes. You may need to modify the WordPress site to remove that header (not recommended for security).
  • Mixed content: If the iframe or proxy loads HTTP resources, the browser will block them, and the padlock will disappear.

Tips

  • Use a reverse proxy instead of an iframe whenever possible because it preserves SEO, allows full control of headers, and maintains the URL in the address bar.
  • Keep the original domain as a backup and for admin access. You can set up a subdomain like admin.original.com to access the WordPress backend without triggering the proxy.
  • Use a plugin like “Better Search Replaceâ€� to update URLs in the database after changing the site URL.
  • Test with a staging site first if you’re not comfortable with server config changes.
  • If you’re using Cloudflare, you can use their “CNAME setupâ€� and “Full (strict)â€� SSL mode to simplify the proxy setup.

Troubleshooting

Site not loading on new domain: Check DNS propagation using a tool like dig or an online checker. Confirm the A record points to the correct server IP. If you’re using a proxy, verify that the proxy modules are enabled and the config is correct.

SSL certificate errors: Re-issue the certificate for the new domain and ensure it covers both www and non-www versions. If you’re using a CDN, set SSL mode to “Full (strict)� and ensure the origin has a valid certificate.

Redirect loop: Temporarily disable any redirect rules on the original site. Check the proxy configuration for the Host header. In Nginx, use proxy_set_header Host $host; to preserve the new domain. In Apache, you may need to set ProxyPreserveHost On.

WordPress admin inaccessible: If you changed the site URL and can’t log in, edit wp-config.php to define WP_HOME and WP_SITEURL back to the original domain, or use FTP to temporarily restore the original URL.

Iframe shows blank or error: The target site likely sends an X-Frame-Options header. You can try adding a Content-Security-Policy header on the iframe page, but the best solution is to use a reverse proxy instead.

Frequently Asked Questions

Does masking a domain affect SEO?

Yes. A reverse proxy preserves the original site’s SEO because the content is served under the new domain, and you can set up 301 redirects. Iframes are bad for SEO because search engines may not index the content properly.

Can I mask a domain without changing my hosting?

Yes, you can use a service like Cloudflare’s “CNAME setup� or a simple iframe, but the iframe method has limitations. For a full solution, you need server-level proxy configuration.

Will my WordPress plugins and themes work with a masked domain?

Generally yes, but plugins that rely on the site URL may need updates. Use a search-replace plugin to update URLs in the database. Some plugins may have hardcoded URLs in their settings.

Is it legal to mask a domain?

Yes, as long as you own the domain and are not impersonating another site. However, if you’re masking a third-party service, check their terms of service.

How long does DNS propagation take?

Usually 24-48 hours, but it can be faster. Use a global DNS checker to see if the record has propagated to your region.

Can I mask a subdomain instead of a full domain?

Yes, the same steps apply. You can create a subdomain like sub.example.com and point it to your WordPress site.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.