Xampp - redirect external url to localhost

I use the Xampp installation to test my files locally before I upload them to my web server. My web pages usually contain a lot of hardcoded links, which means testing any links (or any forms, etc.). I need to change the hard link to point to localhost, and then replace it after I have finished testing.

I am looking for a way to redirect an external url to point to my localhost folder, so I could set it as my site, and then I could make changes before uploading them. For example, if I went to "www.mysite.com/example/view.php" in my browser, I would really look at "localhost / example / view.php".

Is it possible?

+5
source share
4 answers

Two solutions come to me:

  • Use relative URLs (preferred)
  • Add your external URL to the hosts file, which can be found either in

    C: \ WINDOWS \ system32 \ drivers \ etc \ hosts (Windows)

    or

    / etc / hosts (Linux)

    Just add this line:

    www.mysite.com localhost

    Maybe you need to use your ip servers instead of mysite.com, I'm not sure right now

+6
source

I just stumbled upon this.

Use this line in hosts:

127.0.0.1 www.yoururl.com

+4
source

: !

, , . URL- , , "/example/view.php" " http://www.mysite.com/example/view.php". , .

, ( , , ...), . ...

+1

- IP-, -. .

, 202.20.20.20 (IP- -) 192.168.1.10 ( IP- )

This method is redirected after DNS resolution, and not earlier. This and the other method described above (using the Hosts file) are really useful when using software such as wordpress; which captures the development URL in this database.

0
source

All Articles