Masking a Domain Name Using an iFrame


https:// in a browser address bar

If you have an affiliate link you don’t want to show in the browser’s address bar, one way to hide it is to use an iframe. This way, it looks like your domain name in the address bar instead. This article will explain how to quickly and easily accomplish that.

Why Mask a URL or Domain Name?

There are several reasons why you might want to mask a URL with your own domain name. The way I mainly use it is when I’m using an affiliate link and I want people to see to what I’m offering using my brand instead. Then, when they get there, I don’t want them to see the strange looking affiliate URL. I still want them to see my domain name. So, it’s mainly for branding and aesthetic reasons.

I haven’t really measured it but it just seems that doing this helps increase conversions. Also, you’re not revealing the source of where the real website is too easily.

Does URL Masking Always Work?

Nope. There’s a way to prevent your website from being iframed (I’ll show you that later, at the bottom), so if the website you’re trying to iframe is set up that way, this probably won’t work. Doing that is an extra step and most brands don’t take the time to do this, so you really shouldn’t run into this problem too often.

The iFrame Code to Use

The code is simple. I use it all the time. What you’ll want to do is create an HTML file, which is really just a plain text file (not a Word document or anything like that – plain text like Notepad) with the file extension changed to .html instead of .txt – it’s that easy. Then use the code below in that file – changing out the URL you’re masking:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Free Online Workshop - Join Right Now</title>
<body><iframe src="" style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"></iframe></body>

I’ve highlighted in red the items to edit, which are:

  • The page title
  • The frame source (the URL you’re masking)

Leave everything else like it is – so there are just 2 things to edit… simple!


I’m using that code right here:

When you go there, you can see there’s no iframe border at all.

More Information

You’ll need your own website hosting because you do need to host that one file, which you’ll name index.html so that it comes up when people go right to the domain but that hosting can be a lower priced plan. I like using A2 Hosting because their support is great and they even do things like scan websites for vulnerabilities and they also fix them. I love that hosting.

You’ll then need to point your domain name to your hosting. If you don’t have a domain name yet, you can buy it with your hosting at A2.

You can also just set up a directory on hosting your already have. With my second example above, I have the index.html file inside the “3-step-process” folder.

How to Prevent a Website From Being Framed

Here’s how to prevent a website from being loaded in an iframe in case you’re actually trying to stop someone from iframing your website. This is also called clickjacking.

The way I do it is with adding some lines into the .htaccess file. This is a special file, which isn’t accessible by the world but sits next to your index.html file (in the same folder). It has server commands (configurations) in it, so they have to be done exactly right or the page might not load at all.

You may already have this file created. If so, then just add these lines anywhere in the file. If you don’t have the file created, then create a text file called htaccess.txt, upload it to your webspace (directory) and then rename it to .htaccess and you’re done. You’ll do this via FTP or the file manager in the hosting control panel (cPanel).

Just add these lines:

# Block clickjacking
Header always append X-Frame-Options SAMEORIGIN

Or try this:

# Block clickjacking
Header set X-Frame-Options DENY

You just really need the second line in each example but the first line is a comment which says what you’re doing. It’s a good idea to have a comment in there so you remember what each part of this file does since this file can sometimes grow a bit large.

Any Questions?

Again, this is useful for affiliate linking or there are probably 20 other, good uses for it. If you have any questions on this, please write them below and I’ll try to answer them for you.

Incoming Searches:

  • frame madk url



Please enter your comment!
Please enter your name here