Hi Friends,
Today I will show you how to set a mask redirection for your site in Linux server.
What is Mask Redirection?
It is the act of hiding the actual domain name of a website from the URL field of a user’s web browser in favor of another name.
How to achieve this?
There are many ways to do this, including the following examples:
- HTML inline frame or frameset so a frame embedded in the main website actually points to some other site.
- URL rewriting (e.g., mod_rewrite) or aliases to have the web server serve the same page for two different domain names.
- Virtual hosting whereby the HTTP server serves up several different websites based only upon the content of the “Host” HTTP Request Header.
Source: Wikipedia
In this post, I will discuss how to achieve it via HTML inline frame or frameset.
Scenario:
Soruce domain: mytestdomain.com (Note: this is a just a test domain hosted locally in the server for testing purpose).
Destination domain: beanexpert.co.in
We want to redirect the domain mytestdomain.com to beanexpert.co.in in such a way that the domain mytestdomain.com should load the contents of beanexpert.co.in, but the domain mytestdomain.com should show in browser.
How to achieve this?
You need to create a index.html file in the document root of the source domain i.e. mytestdomain.com with the below contents:
<html><head>
<title>mytestdomain.com</title>
</head><frameset rows="100%" scrolling="yes" border="0">
<frame src="https://beanexpert.co.in">
</frameset></html>
That’s it..!! 🙂
IMPORTANT: “src” field will filled up with the destination domain (to which we want to redirect).
Once the URL is masked it displays the URL mask rather than the original URL/domain name. Masking does not affect the content of the actual website, it only covers up the original URL/domain name. Domain masking prevents users from being able to see the actual domain website, whether it be due to length or privacy/security issues.
Without redirection:
After setting iframe in index.html:
Also if you have SSL for the site: mytestdomain.com, then you can add the below code in .htaccess file so that the domain should redirect from http to https and then it will load the contents of destination domain (beanexpert.co.in). Put the below code in .htaccess file:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mytestdomain.com/$1 [R,L]
This way your domain mytestdomain.com will load with https protocol.
If you feel dificulty in doing so, please feel free to comment in the comment section. I will help you to achieve this. 🙂
Have a great day..!!!!
My name is Shashank Shekhar. I am a DevOps Engineer, currently working in one of the best companies in India. I am having around 5 years of experience in Linux Server Administration and DevOps tools.
I love to work in Linux environment & love learning new things.
Powered by Facebook Comments
Leave a Reply