Search The Hostwinds Guides Knowledge Base

URL Masking Using .htaccess

Share This Article

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 yourdomain.com/example and yourdomain.com/example/mask. When domain.com redirects to yourdomain.com/example/mask it would not switch the URL, it would continue to be yourdomain.com/example. 

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. 

When someone opens up yourdomain.com 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.

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

When you put this code into your .htaccess you will redirect and see the content for yourdomain.com/example/mask but you will still see the URL for yourdomain.com/example. 

Related Articles