Search The Hostwinds Guides Knowledge Base

URL Masking Using .htaccess

Share This Article [TheChamp-Sharing]

There are two main types of redirects, temporary and permanent. We will focus on another type of redirect called URL Masking in this guide and review how to accomplish URL Masking by Editing a .htaccess file.

Let’s get started.

What is URL Masking?

URL masking would be when you redirect to a new domain but instead of the URL changing it would stay the same. For example, if you have a domain mask redirect between and When redirects to it would not switch the URL, it would continue to be 

How Do I Create a URL Mask Redirect?

There are a couple of ways to make a redirect for your domain, like using code with HTML. We are going to be using your .htaccess file for this redirect mask.  If you have not already created an .htaccess file go check out our guide: Creating And Editing An .htaccess File. That guide will show you how to create and some ways to edit your .htaccess.

Now that you have your .htaccess file created we can go ahead and use the following code to redirect your website with a URL mask. 

#Making a URL Mask.

RewriteEngine On
RewriteRUle ^example/?$ /example2/mask

When someone opens up it will show the contents of another folder in example2 above. Replace example above and example2 to display the desired content that you wish to have displayed.

#Redirect a domain to a specific url
RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*) [P]

In the above example, replace with your domain name and the domain that you wish to send this to in

When you put this code into your .htaccess you will redirect and see the content for but you will still see the URL for 

Related Articles