WAMP - Remove localhost from project URL

2019-01-10 09:25发布

The URLs of my projects in WAMP are not resolving as I'd expect. For example, I'd expect the project in the folder c:\wamp\www\project1 to have the URL http://project1/, but it actually has the URL http://localhost/project1/.

This can cause problems when accessing server variables. How do I fix this?

14条回答
爷、活的狠高调
2楼-- · 2019-01-10 09:55

Create a virtualhost like RiggsFolly said.

And try to uncomment LoadModule rewrite_module modules/mod_rewrite.so in httpd.conf

查看更多
Rolldiameter
3楼-- · 2019-01-10 09:56

Okay, I had this problem. So, I troubleshooted the problem and traced it to an actual solution, NOT A HACK.

The SOLUTION :

  1. Right-Click WAMP-server icon
  2. Select WAMP Settings,
  3. Select (enable) option Add localhost in URL


DONE. The remainder is FYI of how and why.


Note: localhost/myproject.php or myproject.php. Although the solution was already accepted, I saw some posts that got me confused. The accepted solution is based on a single project wrt different server applications, based on the OP's specific question, and how to influence that single project in question. But all the other solutions are hacks and don't really answer the solution to the OP's question, but do bring up a good point about the URL. So, according to the other "solutions", here is how to toggle the localhost reference in the URL. Hence my additional solution added to the mix.


This is a toggle switch.

Troubleshooting Process (no hacking involved):



Let's peek at the index.php

enter image description here


Let's look at the config file. Note the variables and Array?

enter image description here


Here is the array. A variable used earlier. Let's see... Oh, it tells us where and what to do.

enter image description here


As noted in the SOLUTION:

enter image description here

查看更多
登录 后发表回答