View Full Version : Adding domain name to my localhost server?

02-20-2011, 03:04 PM
I'm creating and running a website called Project PHP through my XAMPP software. But, I'm trying to add a reCaptcha to the "Register" part of it. The problem is though, when I try to sign up for the reCaptcha keys, it requires me to type in the URL of my website.

I tried to use the localhost one (You know, "localhost/projectphp/index.php"), but that would not work. I assume that there is some way to add a domain to my website, right? I must figure this out.8-)

03-02-2011, 11:05 AM
you need to change 2 files for this to work

navigate to...


and open the HOST file in a text editor

There will be an entry of... localhostJust add yours to the list like this. localhost mysite.dev //<< your domain
NOTE: dont add valid domains like .com else you wont be able to navigate to the online version as the local version will override the DNS lookup. I use .dev for example then there is no confusion.

The above will map specified domains to the local IP address which resolves to your web root

Now you need to tell apache where to route specific URI requests to a specific directory

Edit the following file...


Its located in your apache directory.

(WAMP path: C:\wamp\bin\apache\Apache2.2.11\conf\extra)

add the following to the bottom of the file

// ServerName is the new domain which is used in the browser. The one you defined in the HOST file

// DocumentRoot is the path to the site directory within your www root. You need to use a complete file path from C:

<VirtualHost *:80>
ServerName mysite.dev
DocumentRoot C:/path/path/mysite
Finally, bounce the apache service and you should be cooking on gas!