URL masking can be useful when you want to present a cleaner, more branded URL to your users or when you want to make a subdomain look like it’s part of your main domain. For example, you might have a subdomain like blog.yourdomain.com that you want to appear as yourdomain.com/blog. Let’s learn the process of masking a subdomain URL in WordPress.
Methods to Mask URLs for Subdomains in WordPress
1. Using Domain Forwarding with Masking
This method is typically managed through your domain registrar’s control panel and involves setting up domain forwarding with masking.
- Log into your domain registrar account.
- Access the DNS settings for your domain.
- Set up domain forwarding.
- Create a new forward from your subdomain (e.g., blog.yourdomain.com) to the URL you want to display (e.g., yourdomain.com/blog).
- Enable masking.
- When setting up the forward, look for an option to enable masking or URL cloaking. This ensures that the browser shows the desired URL (e.g., yourdomain.com/blog) instead of the subdomain URL.
- Test the forward.
- After setting up the forwarding and masking, visit the subdomain URL to ensure it displays as intended.
2. Using a WordPress Plugin
If you prefer not to use domain forwarding, you can use a WordPress plugin to achieve a similar effect.
- Install a URL masking plugin.
- Several WordPress plugins, such as Pretty Links or Redirection, allow you to mask URLs.
- Create a masked link.
- After installing the plugin, create a new masked link. Set the target as your subdomain (e.g., blog.yourdomain.com) and the link as the URL you want users to see (e.g., yourdomain.com/blog).
- Test the masked URL.
- Once the link is created, test it to ensure it displays the correct content while showing the desired URL.
3. Using .htaccess for URL Rewriting
If you have access to your server’s .htaccess file, you can use URL rewriting to mask the subdomain.
- Access the .htaccess file.
- Use an FTP client or your hosting control panel to edit the .htaccess file located in your WordPress root directory.
- Add a rewrite rule.
- Insert the following code into your .htaccess file:
RewriteEngine On RewriteCond %{HTTP_HOST} ^blog.yourdomain.com [NC] RewriteRule ^(.*)$ https://yourdomain.com/blog/$1 [P,L] - Replace blog.yourdomain.com with your actual subdomain and yourdomain.com/blog with the URL you want to display.
- Insert the following code into your .htaccess file:
- Save and test.
- Save the changes to your .htaccess file and test the subdomain URL to ensure it’s masked correctly.
Ensuring Effective URL Masking
Masking a subdomain URL in WordPress can be achieved using various methods, from domain forwarding with masking to using plugins or server-side URL rewriting. Each method has advantages depending on your technical skills and the level of control you need. By carefully choosing and implementing the appropriate method, you can successfully mask your subdomain URL, presenting a cleaner, more cohesive experience for your website visitors.
Interesting Reads:
How To Add Video Background In WordPress Using HTML


