WordPress GuideBuild → Mask URL For a Subdomain

How to mask the URL for a subdomain in WordPress

Your guide to bare metal management best practices.

URL masking can help you keep a clean, on-brand web address even when the actual content is served from a different source. 

For WordPress users, masking a subdomain URL involves a mix of DNS setup, server-side rules, and sometimes plugins. Each step needs to be done correctly to make sure your visitors have a seamless experience and search engines don’t get confused.

Let’s walk through everything you need to know to mask a subdomain URL and make your WordPress site look and function the way you want.

Get fast, reliable hosting for WordPress

Power your site with the industry’s fastest, most optimized WordPress hosting

What does it mean to mask a subdomain?

Masking means keeping the subdomain visible in the browser’s address bar while serving content from a different location, usually the main domain. For example, if someone visits dashboard.example.com, they still see that in the address bar, even though the content might be coming from example.com.

Masking vs redirecting: what’s the difference?

Redirecting, on the other hand, sends users from one URL to another, and the address bar updates to show the new URL. This is good for SEO in some cases but not ideal if you want to maintain a branded subdomain.

Why you might want to mask a subdomain

Configure DNS for subdomain masking

DNS setup is the first step. You need to make sure your subdomain points to the correct server or domain.

Create a CNAME record

This tells browsers that sub.example.com should resolve the same as example.com.

Optional: Add an A record

Some hosting providers may require you to point the subdomain directly to an IP address.

Not all setups need this, but it’s useful for more direct control.

Use .htaccess to redirect subdomain traffic

If you’re on an Apache server, WordPress lets you control redirection through the .htaccess file. This lets you serve main site content under the subdomain URL.

Access and edit your .htaccess file

Add rewrite rules for masking

Paste the following into your .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.example\.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,P]

Here’s what each line does:

Test the result

Visit sub.example.com. You should see the same content as example.com, but the URL should remain sub.example.com.

Check your site on different browsers and devices to confirm it behaves consistently.

Alternative masking for NGINX servers

Apache uses .htaccess, but if you’re using NGINX, you’ll need to update your server configuration directly.

Use a reverse proxy block

In your NGINX config file, add:

Then restart NGINX to apply changes.

This proxies content from the main domain while keeping the subdomain URL intact.

Use an iframe to mask the subdomain (not ideal)

This method is outdated but simple. It involves using an HTML file with an iframe that loads your main domain.

Example iframe masking file

Create a basic index.html file under the subdomain directory:

Why it’s not recommended

WordPress plugin options for masking or redirecting

If you don’t want to edit server files directly, some plugins can help manage masking or redirection inside WordPress.

WP Hide & Security Enhancer

WP Hide & Security Enhancer is a powerful plugin that lets you hide or change core WordPress paths like wp-admin, wp-login, and even plugin directories. While it’s primarily a security plugin, it also helps rewrite how URLs appear on your site.

Strengths:

Best for: Site owners who want to cloak and customize many aspects of WordPress URLs for branding or security purposes.

Pretty Links

The Pretty Links plugin was built for affiliate marketers but is useful for anyone wanting to cloak URLs or create custom shortlinks. It doesn’t technically proxy content but can be used to redirect or mask sub-paths.

Strengths:

Best for: Affiliate marketers and content creators who want to cloak or shorten links using their domain or subdomain.

Redirection

Redirection is a long-standing and trusted plugin for managing 301 redirects, conditional redirects, and logging 404 errors. It won’t keep the subdomain in the address bar like a proxy, but it’s ideal for clean, consistent redirection behavior inside WordPress.

Strengths:

Best for: Users who want to manage complex redirection logic in WordPress without needing FTP or server access.

Things to consider before masking

SEO implications:

Hosting limitations:

WordPress settings:

Additional resources

How to build a WordPress site →

A complete beginner’s guide that covers 9 key steps to a successful launch

How to convert Figma to WordPress →

Learn how to efficiently convert Figma designs into fully functional WordPress websites without losing design fidelity.





















How to use WordPress Gutenberg blocks →

A complete beginner’s guide to Gutenberg blocks