I never noticed this before, but one of my sites has domain forwarding with masking enabled, which is adding an iframe to wrap the site. This is bad for SEO and bad for responsive design. Is it possible to forward the domain with masking without using iframes?

My ultimate goal:

I have two domain names:

domain1.com domain2.com

domain1.com points to site1 on my server (A record). I wanted to point domain2.com to a page on that same site1. So when I type domain2.com arrive at domain1.com/mypage, but the URL display domain2.com

This works with forwarding with masking, but as I pointed out, that's not a good solution.


So I have switched things around a bit.

Now I have both domains pointing to the same IP address. In Cpanel I've added the second domain as a parked domain. That way I can navigate the site with either domain without the URL switch up top.

Now this is what I am trying to accomplish:

If the site is accessed via domain2 then the user should be redirected to another page (not the home page). I believe I can accomplish this with htaccess which I know little about. But the idea is to do something similar to this in htaccess;

if(domain2){ //redirect to domain2.com/domain2-page }else{ //redirect to domain1.com }

  • Why wouldn't you want to use a redirect? Commented Jan 14, 2016 at 23:02
  • What are other options? I can't point the dns to my server.
    – gdaniel
    Commented Jan 14, 2016 at 23:06
  • @gdaniel Many registrars and DNS providers have options to set Meta Tags, for example. You could also use a proxy server, but keep in mind that if you mask a page that's crawlable under another domain, you could end up with duplicate content. Search engines are really designed to index content under one domain or the other, so would suggest to move your content to the domain where you want it indexed.
    – dan
    Commented Jan 15, 2016 at 2:19

2 Answers 2


You can use A record to point both domains to the same IP address. Then you can configure the webserver to serve both sites from the same directory. Doing so is usually a simple matter of making sure that each virtual host is set to serve content from a common directory.

Your other option is to run a reverse proxy server on your second domain. When somebody hits /page.html on domain2:

  • The server at domain2 would fetch domain1/page.html
  • The server at domain2 might rewrite links and cookies to be appropriate for domain2
  • The server at domain2 would re-serve the content

A reverse proxy will work even when you can't host the sites on the same computer, but it introduces extra processing which can lead to performance problems.

In either case, you are going to have duplicate content problems for search engines. Search engines are going to choose one of your domains to index and ignore the other. It is usually better to redirect one domain to the other. If you can't do that, you should user link rel canonical tags to tell search engines which domain to prefer.

  • So I was testing something similar to this yesterday. I pointed both A records to the same IP, and setup the website in a way that it can use either address. This works, and it keeps the address on the URL bar. However, I am still stuck trying to write a htaccess that redirects the second domain to a child page and grandchild pages. Otherwise both domains land on the home page.
    – gdaniel
    Commented Jan 15, 2016 at 15:08
  • Then point the directory in the virtual host of domain2 to a subdirectory of domain1? Commented Jan 15, 2016 at 15:09
  • For some reason when I do a redirection of the parked domain, the domain switches to domain1 on the address bar.
    – gdaniel
    Commented Jan 15, 2016 at 17:35
  • Redirects change the domain name in the address bar. You can have two sites with the same content (don't use redirects), but it isn't great for SEO. Commented Jan 15, 2016 at 17:56

You could just create another domain as you said, just place all your website there(meaning data - all files), but use the same or a mirrored database additionaly. Depends on how often you update your code, etc, you can just create git repo and auto-pull on change for the other website, just adding a small shell automaticaly renaming string domain1.com to domain2.com, you can accomplish this by awk/sed more and possible solutions can be found here on a StackOverflow question : AWK/SED how to do a recursive find/replace of a string?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.