Posted by: gerritvisagie on: April 13, 2011
Tired of always using http://localhost/mysite ? want it to display mysite.com?
Well same here fellow Apache users.
Brows to your apache folder
>apache>conf>extra
Edit the httpd-vhosts.conf and add the following
(make sure to use the forward slash and not just copy and paste form the clipboard )
NameVirtualHost yourwebsite.com:80
<VirtualHost yourwebsite.com:80>
DocumentRoot C:/root/of/your/site
ServerName yourwebsite.com
</VirtualHost>
Make sure to also add your localhost to ensure your phpmyadmin and other extentions still work.
NameVirtualHost localhost:80
<VirtualHost localhost:80>
DocumentRoot C:/xampplite/htdocs
ServerName localhost.com
</VirtualHost>
Next up on your local drive go to:
C:\Windows\System32\drivers\etc
And edit the hosts file to look like this
127.0.0.1 localhost
127.0.0.1 yourwebsite.com
(Note do not define any real website addresses, this is your computers host setup file and will direct all references to the defined domain to the local machine)
Last and not least make sure your appache httpd.conf allows you to view files in the directory by adding
<Directory “C:/root/of/your/site/”>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Note: Do not use any unsafe characters in folder names. If your apache does not start up after the changes, check the folder names for any spaces an spelling mistakes .