0

I have a website hosted with a domain (www.example1.com).

When viewers access this website, I want everything to remain exactly as is however, I want to change the URL in the browser to appear as www.example2.com.

Is this possible?

cleverpaul
  • 935
  • 4
  • 12
  • 28
  • 2
    Why? The only reasons that spring to mind are not nice ones. Also, if you navigate to example1 then the URL will display as example1. What not-nice people do is then use tricks like an iframe to navigate to example2 without the user noticing. – Dave S May 31 '17 at 01:10
  • I have technical reasons for this. I promise it is nothing malicious. :D – cleverpaul May 31 '17 at 01:32
  • @cleverpaul and I believe you, fellow denizen of the Internet! Could using subdomains solve your problem? –  May 31 '17 at 01:41

2 Answers2

0

"When viewers access this website, I want everything to remain exactly as is however, I want to change the URL in the browser to appear as www.example2.com."

No, you can't do this with Chrome, Edge, IE, Firefox, etc. because they don't want to let you impersonate apple.com or microsoft.com etc.

You can only do the reverse: have your example1.com URL be visible while you display content from example2. This could be done with tricks like an iframe or fetching the content server-side with cURL.

If you want to hide the URL for example1.com you'll need to make your own browser using a chromium widget, the IE web control, webkit. If it's your own browser you can display anything you want in the address bar or show no address bar at all.

Dave S
  • 1,427
  • 1
  • 16
  • 18
0

You can try the following:

  1. You should own both of the domains example1.com and example2.com.
  2. The domain example2.com should point to the IP of the server hosting your web app In your name server configuration.
  3. The domain example1.com should be configured to forward to example2.com (also from the name server).

So, visitors to example1.com will be redirected to example2.com and see the content of the web app while the address bar remains pointing to example1.com.

Another solution:

  1. Both domains should point to the IP of the server hosting your web app.
  2. In the web server, you can configure to redirect to example2.com only if the request was for example1.com. Here is an answer about doing so in Apache web server.

Using PHP

You can see this answer about checking the host domain name and then you can redirect if the domain is example1.com

Amr Eladawy
  • 4,193
  • 7
  • 34
  • 52