How to change the URL from "localhost" to something else, on a local system using wampserver?

user961627 picture user961627 · Jul 15, 2013 · Viewed 190.5k times · Source

On a Windows machine, there's a system running on the local wampserver, but while the application is running on localhost, the URL says otherwise.

While I would expect the URL to be like this based on the directory structure:

http://localhost/pro/include/db_report.php

The developer has managed to do this:

http://ap-mispro/pro/include/db_report.php

So instead of localhost, the URL says ap-mispro.

And both URLs work fine.

How is the second URL made? I tried checking out the wampmanager.ini and wampmanager.tpl but maybe I didn't know what to look for?

Answer

Abhishek Goel picture Abhishek Goel · May 29, 2014

WINDOWS + WAMP solution

Step 1
Go to C:\wamp\bin\apache\Apache2.2.17\conf\
open httpd.conf file and change
#Include conf/extra/httpd-vhosts.conf
to
Include conf/extra/httpd-vhosts.conf
i.e. uncomment the line so that it can includes the virtual hosts file.

Step 2
Go to C:\wamp\bin\apache\Apache2.2.17\conf\extra
and open httpd-vhosts.conf file and add the following code

<VirtualHost myWebsite.local>
    DocumentRoot "C:/wamp/www/myWebsite/"
    ServerName myWebsite.local
    ServerAlias myWebsite.local
    <Directory "C:/wamp/www/myWebsite/">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

change myWebsite.local and C:/wamp/www/myWebsite/ as per your requirements.

Step 3
Open hosts file in C:/Windows/System32/drivers/etc/ and add the following line ( Don't delete anything )

127.0.0.1 myWebsite.local

change myWebsite.local as per your name requirements

Step 4
restart your server. That's it


WINDOWS + XAMPP solution

Same steps as that of WAMP just change the paths according to XAMPP which corresponds to path in WAMP