12

I have a problem with Wamp which never happened to me before, cannot find what's wrong. I have a few projects located in my www folder ( running windows 7 ).

My hostfile has the line 127.0.0.1 localhost uncommented

When I go to http://localhost/ or http://127.0.0.1/ and click on a project name like "mysite" from the main Wamp panel page, the link just points to "mysite" and not "http://localhost/mysite"

Therefore I can't see any sites, what should I do ?

Deleted User
  • 2,551
  • 1
  • 11
  • 18
mlclm
  • 725
  • 6
  • 16
  • 38
  • As in, your URL changes from `http://localhost/` to `mysite`? – Russell Uhl Jun 25 '14 at 12:29
  • it doesnt change, it is directly mysite . Instead being http://localhost/mysite – mlclm Jun 25 '14 at 12:30
  • 2
    possible duplicate of [Wamp remove localhost from URL](http://stackoverflow.com/questions/23551763/wamp-remove-localhost-from-url) or yuo can read this post on the WAMPServer forum. http://forum.wampserver.com/read.php?2,124482 – RiggsFolly Jun 25 '14 at 14:15
  • Thanks for pointing that out and for the link. I hadn't noticed they updated wamp recently. I will look further to use virtual hosts. – mlclm Jun 25 '14 at 14:27
  • Great, once you get the first one done you will never look back they are just so useful. – RiggsFolly Jun 26 '14 at 08:37

14 Answers14

37

After thorough research, I found out the solution which worked for me as well..

open wamp/www/index.php.

Change this line:

$suppress_localhost = true;

To :

$suppress_localhost = false;
slfan
  • 8,950
  • 115
  • 65
  • 78
Olasunkanmi
  • 902
  • 15
  • 23
  • 1
    You do not invent the wheel twice, wampserver have the structure of making things by .conf files, from there you do the change only and not in more than that place other than that it will be a hell of settings everywhere. so in wampmanager.conf where the line `urlAddLocalhost = "off"` you turn it to "on" – Eagle_one Sep 23 '17 at 18:07
30

For the latest versions on Wamp, the file has changed the code as follows:

$suppress_localhost = ($wampConf['urlAddLocalhost'] == 'off' ? true : false);

So it is now configurable from the Wamp Aestan Tray menu.

For Wampserver 3.0.6, I was able to do this by the following:

  1. Right click on wamp icon on tray on the right.
  2. Go to "wamp settings"
  3. Enable "Add localhost in URL"

If you see the green tick mark, it is enabled. Now refresh your localhost home page and check URLs.

e0k
  • 6,961
  • 2
  • 23
  • 30
Vikram Dhanjal
  • 321
  • 3
  • 7
4

Adding Localhost in url is not a suggested by wamp, wamp expect that each project contains a virtualhost.This provides a level of control for framework development. So for instance if your project is stackone, you need to create a virtual host for that called stackone:How to create a virtual host?

--Create a directory/folder in wamp64/www (example wamp64/www/projectone)

--Go to kickstart you wamp server and type localhost on your browser

--At the bottom left you should see add local virtual server. fill in the project name,(e.g projectone),fill in the path.(e.g c:\wamp64\www\projectone).click start creation.

--You will need to restart DNS. Right click on the notiication icon of wamp, hover on tools, you should see restart DNS. You can now copy your files to the directory you created. I added some images below (wamp 3.0.6)

Adding Virtual Host,Restarting DNS

K-Square
  • 63
  • 5
  • I have followed these processes but each time I click on the project name, Instead of the domain to load something like: localhost://testproject, Its directing me to the website. what could be wrong ? – Olasunkanmi May 31 '18 at 16:53
3

You can update "urlAddLocalhost" variable in "wamp64/wampmanager.conf" file to on/off. By default it is "off".
My wamp version is 3.0.6.

urlAddLocalhost = "off" 

enter image description here

Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90
2

I prefer the end-user way to change wamp's behaviour. Right click on WAMP notification icon -> Wamp Settings -> Add localhost in url.

victor_luu
  • 129
  • 1
  • 2
2

No need to open and edit www/index.php. Just write click on wamp icon => go to wamp settings => then look for "Add localhost in url

1

Although its not a problem. Linking been disabled by Wamp Devs. Check this article link, its well written and explained the matter.

WAMP - Remove localhost from project URL

Community
  • 1
  • 1
Advoot
  • 731
  • 6
  • 5
1

In WAMPSERVER 3.1.x

Open wamp/www/index.php

Go to line number 33

Change this line:

$suppress_localhost = ($wampConf['urlAddLocalhost'] == 'off' ? true : false);

To:

$suppress_localhost = ($wampConf['urlAddLocalhost'] == 'on' ? true : false);

Save and close the file.

OR

Right click on system tray Wampserver icon and hover on,

Click Wamp Settings option

After that choose this: Add localhost in url

Sanu
  • 330
  • 3
  • 15
0

In the latest version

CHANGE THIS

$suppress_localhost = ($wampConf['urlAddLocalhost'] == 'off' ? true : false);

TO THIS

$suppress_localhost = ($wampConf['urlAddLocalhost'] == 'off' ? false : false);
plaga
  • 1
0

WampServer Version 3.1.0 64bit In Wampmanager.conf you will find a line:

urlAddLocalhost = "off"

Change it to "on" Thats it!

Eagle_one
  • 426
  • 4
  • 15
0

In Wamp server 3.0.0:

Open wamp/www/index.php and head to line number 33 and replace off by on.

if(!empty($wampConf['urlAddLocalhost']) && $wampConf['urlAddLocalhost'] !== "on")

You may now uncheck the "Add localhost in url" in the Wamp menu.

Horai Nuri
  • 5,358
  • 16
  • 75
  • 127
0

Right-click on the wamp icon then go to the Wamp Setting => Add localhost in url

enter image description here

Sandeep Sherpur
  • 2,418
  • 25
  • 27
0

In the Version 3.2.5 go to the line 375 in X:wamp/www/index.php:

Change this:

$projectContents .= '<li>'.$file.'</li>';

For this:

$projectContents .= '<li><a href="'.str_replace('.conf','',$file).'">'.$file.'</a></li>';

That's it!

0

The previous methods are no longer working in 2022. There's no urlAddLocalhost to be found, and no Add localhost in URL menu option.

The new method is to open wamp/wampmanager.conf and set:

LinksOnProjectsHomePage= "on"

This is correct as of WampServer version 3.2.9.

SQW
  • 1
  • 1