4 Replies - 1844 Views - Last Post: 29 December 2010 - 05:02 PM

#1 Merko   User is offline

  • New D.I.C Head

Reputation: 10
  • View blog
  • Posts: 42
  • Joined: 23-November 10

Redirect one domain to another (Using Windows Hosts-file)

Posted 29 December 2010 - 01:13 PM

Hello.

Let's say i got two domains. "MyDomain.com" and "Example.net".

How can i make it so, if you go to Example.net/stuff/index.php, you will automaticly go to MyDomain.com/stuff/index.php ?

I tried to use this in my windows hosts file:
mydomain.com example.net

But that didn't work.

If i ping "mydomain.com", I can't use that IP i get in return, since there is multiply domains hosted on the same IP.
Is there any easy solutions for this? - And also, I dont have access to the "example.net"-domain.

Thanks :)

This post has been edited by Merko: 29 December 2010 - 01:15 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Redirect one domain to another (Using Windows Hosts-file)

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Redirect one domain to another (Using Windows Hosts-file)

Posted 29 December 2010 - 03:32 PM

Are both of the domains owned by you?

Can you share what they are?

If the sites already run php, then why do this on your computer? Only one node will be effected by the change, & that's your machine. Why not use forwarding at the domain register, or any number of ways in php? Are you up to something fishy?
Was This Post Helpful? 0
  • +
  • -

#3 Merko   User is offline

  • New D.I.C Head

Reputation: 10
  • View blog
  • Posts: 42
  • Joined: 23-November 10

Re: Redirect one domain to another (Using Windows Hosts-file)

Posted 29 December 2010 - 04:08 PM

No, only one domain is mine, and like I said, i dont have access to the other domain, so i can't modify anything there.

Lets just say i have an old program i wrote, that "talks" to the other domain which I dont have access to anymore. and the sourcecode of my program is also lost.
I do have the *.php-files that my program "talks" too, thats why i wanted to just upload them to my new webserver and find a way so my software can go to my new domain instead of the old one.

This software is running on my serverbox at home, and I only want the change to affect that machine.

I'm not up to anthing fishy, no. :)

If its not possible by doing it with the Windows hosts-file, is there any recommendation for software i can use for the job?

Thanks. :)
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Redirect one domain to another (Using Windows Hosts-file)

Posted 29 December 2010 - 04:15 PM

After you update the hosts file, you need to flush the dns cache.

ipconfig /flushdns


Was This Post Helpful? 0
  • +
  • -

#5 Merko   User is offline

  • New D.I.C Head

Reputation: 10
  • View blog
  • Posts: 42
  • Joined: 23-November 10

Re: Redirect one domain to another (Using Windows Hosts-file)

Posted 29 December 2010 - 05:02 PM

View Postno2pencil, on 29 December 2010 - 03:15 PM, said:

After you update the hosts file, you need to flush the dns cache.

ipconfig /flushdns


Yes i know, thanks.
But it seems it doenst let me have my domain like tihs:

MyDomain.net Example.com

It only works if i place an IP instead of "MyDomain.net".
But the IP that i got my domain name on have multiply domains on the server, so i can't use the IP. I'm stuck.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1