-1

I want to put a live wordpress site in my local environment, let's say for example the site url is www.test.com , this opens the page, so when I normally set up a local environment in /var/www/html (using lamp btw) i create a directory let's say test (/var/www/html/test) and update in the database the siteurl and home links to http://localhost/test

So when I write in the browser http://localhost/test it will open....but I want to change the hostname and url directy, I want to have in my local environment something like http://local.test.com

dreid
  • 163
  • 2
  • 17

1 Answers1

2

Here is simplest way to convert your localhost to a domain name
if you are on windows follow this steps;

1- goto C:\Windows\System32\drivers\etc (C:\windows is your windows installation folder)
2- seek on a file called "hosts" (may be marked as hidden or system)
3- open it with text editor like notepad
4- find line containing "127.0.0.1 localhost"
5- add new line below it containing "127.0.0.1 www.google.com"
6- save file and its done!

Note: replace www.google.com with every domain name that you like
Note: if you have problem in editing this file just boot your windows in safe mode and you will be able to edit and save it

UPDATE
if you are using Linux or Mac there is same way!
in linux edit this file /etc/hosts
in mac edit this file /private/etc/hosts

Netlog
  • 137
  • 1
  • 9
  • OP is using LAMP (L = Linux) and this just appears to be a way of disabling Google on a PC – RiggsFolly Apr 25 '19 at 13:34
  • Yes por changing the localhost I have that sorted out, it's the other thing I am more concern but thanks – dreid Apr 25 '19 at 13:41
  • @RiggsFolly there is same way in linux and mac , solution updated by hosts file in linux and mac – Netlog Apr 25 '19 at 13:42
  • @dreid you can add multiple line like this:
    127.0.01 site1.test.com
    127.0.01 site2.test.com
    And handle them by HTTP-HOST to create a relation between sub directory and defined domains :)
    – Netlog Apr 25 '19 at 13:46
  • @Netlog this for example is not a solution for me, if I change my 127.0.0.1 to local.test.com the link in the browser is going to be http://local.test.com/test , I dont want the /test – dreid Apr 25 '19 at 13:46
  • 1
    another way is using hosts file + htaccess file for url rewriting to handle this issue – Netlog Apr 25 '19 at 13:51
  • @Netlog yes I will try to use the htaccess , thank you – dreid Apr 25 '19 at 14:42