How to change localhost/sample/index.php to dev.sample.com? I make it in ubuntu using nginx I wonder how to make it in windows using wamp server.
First you need to add this line:
127.0.0.1 dev.sample.com
To C:\Windows\System32\drivers\etc\hosts
(edit with notepad).
After that, uncomment the line (around line number 512):
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
Of C:\wamp\bin\apache\apacheX.Y.Z\conf\httpd.conf
by removing the inital #
, so you get:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Finally, edit C:\wamp\bin\apache\apacheX.Y.Z\conf\extra\httpd-vhosts.conf
by adding this to the end of the file:
<VirtualHost *:80>
DocumentRoot "c:/YOURPROJECTPATH/sample"
ServerName dev.sample.com
</VirtualHost>
The apacheX.Y.Z
stands for the Apache version your WAMP is using.
You can check more examples on how to create virtual hosts in the Apache's docs examples (WAMP = Windows+Apache+MySQL+PHP).
Once you're done with these edits, left click the WAMP icon near the window's clock, go to Apache > Service > Restart Service and you can now use the new URL. A minor suggestion: you can choose more uncommon URLs, e.g. sample.developer
so you don't end up on a real website when Apache service is down.
You can leave two lines in the C:\Windows\System32\drivers\etc\hosts
file:
127.0.0.1 localhost
127.0.0.1 dev.sample.com
Or you can use the same line for this:
127.0.0.1 localhost dev.sample.com
However, I suggest that you don't pile up many references in one line (4 to 5 should be ok). It's preferable to have more lines to the same IP.
Along with your new site's virtual host, you can also have this in C:\wamp\bin\apache\apacheX.Y.Z\conf\extra\httpd-vhosts.conf
(above or below the other):
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
</VirtualHost>