0

I'm trying to change how I access my website from WAMP server. I can access it like xxx.xxx.xxx.xxx/name, yes, it works perfectly fine. I searched up on how to change "xxx.xxx.xxx.xxx/name" to a domain name like www.name.com, I got some results but none of them worked. These are the things I did:

First I went to my host file

C:\Windows\System32\drivers\etc

, added a line "127.0.0.1 mytestdomain.com", this is how it looks: host file

Next, I changed "#Include conf/extra/httpd-vhosts.conf" to "Include conf/extra/httpd-vhosts.conf" from httpd.conf located at:

"D:\wamp64\bin\apache\apache2.4.27\conf"

.

Lastly, I added

<VirtualHost mytestdomain.com>
    DocumentRoot "D:/wamp64/www/myTestDomain/"
    ServerName mytestdomain.com
    ServerAlias mytestdomain.com
    <Directory "D:/wamp64/www/myTestDomain/">
        Order allow, deny
        Allow from all
    </Directory>
</VirtualHost>

on "httpd-vhosts.conf" located at:

"D:\wamp64\bin\apache\apache2.4.27\conf\extra"

Oh, and yes, this is inside myTestDomain folder: myTestDomain

After doing all this, I restarted WAMP and went to my domain main, but it doesn't seem to be working, meanwhile "xxx.xxx.xxx.xxx/myTestDomain" does seem to be working.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
ckvywk
  • 19
  • 4

1 Answers1

0

Your HOSTS file should look like this

127.0.0.1  localhost
127.0.0.1  mytestdomain.com
::1  localhost
::1  mytestdomain.com

Your Virtual Host definition like this

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/wamp64/www
    <Directory  "D:/wamp64/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:/wamp64/www/myTestDomain/"
    ServerName mytestdomain.com
    ServerAlias mytestdomain.com
    <Directory "D:/wamp64/www/myTestDomain/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

Alternatively open the wampserver home page and use the Add a Virtual Host link under the Tools menu, and it will all be done for you correctly.

NOTE: Using .com is a bad idea unless you actually intend to host your live site from your PC, instead use a .dev for example. Change the HOSTS file accordingly.

Bigger NOTE: Hosting a live site from a PC is a very bad idea. If you are using a desktop OS it is not configured to cope with more than 30 external connections so if your site gets even vaguely popular, users will get a terrible experience, most of them queuing for connections for page parts to be downloaded.

Community
  • 1
  • 1
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • Thank you for the reply, and precisely for the notes! But, I'm not trying to host a big site, just for educational purposes. Once again, thank you! – ckvywk Oct 22 '17 at 14:47
  • Oh, can I access the hosted website on other devices, on entirely different connection? With the DNS. – ckvywk Oct 22 '17 at 14:57
  • If I read between the lines I am guessing you are talking about accessing this site from a phone or tablet. If my guess is right [have a look at this answer, it may help you](https://stackoverflow.com/questions/43016713/wampserver-access-server-from-mobile-phone/43018881#43018881) – RiggsFolly Oct 23 '17 at 08:19