wampserver homepage only visible from localhost

2019-06-07 08:53发布

Recently I used WAMP server to set up a server environment in a Windows machine. Everything works great, but I have a little problem: everyone can access the wampserver homepage, therefore they can see other webpages hosted in the same server, the server file system, etc.

The URLs of the webpage have the following format: hostname/project1, hostname/project2... The main problem is that, anyone can see all the projects that are hosted by going to the direction of the hostname because this will lead to the wampserver homepage, and I would prefer that this homepage could be accessed only in the localhost of the windows host. Is there any way to do that? I'm guessing that I will need to modify some parameters in configuration files, but I have no idea wich ones...

3条回答
Rolldiameter
2楼-- · 2019-06-07 09:31

It should be possible to block other users using the windows firewall. You could also use a .htaccess file like this one:

Order deny,allow
Deny from all
Allow from 127.0.0.1

You will have to make sure that AllowOverride is set to All in the apache configuration and that the .htaccess wil be applied to all subdirectories too, otherwise your projects will still be available.

查看更多
Luminary・发光体
3楼-- · 2019-06-07 09:33

If you intend to block access to all sites hosted on this computer from outside access, you can do this in your main apache configuration file at <installation drive>/wamp/bin/apache/Apache<version number>/conf/httpd.conf. .htaccess is more for per-site configurations, though it will certainly work if you put it in the main www directory.

To disallow outside access to the www folder (open by default) find the part of the apache configuration file (path shown above) that looks like:

<Directory "<installation drive>/wamp/www">
    # There will be comments here and some options like FollowSymLinks and AllowOverride
    Order Allow,Deny
    Allow from all
</Directory>

And change it to:

<Directory "<installation drive>/wamp/www">
    # There will be comments here and some options like FollowSymLinks and AllowOverride
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>

If your goal is not to block outside access to all of your sites, it would help to know more about your set up. And if your goal is only to block the 'localhost' page and still allow access to, say, 'localhost/site1' then this question may be a duplicate of this.

Edit: As you point out, there is not a good resolution for the question I linked. Assuming you have your public sites set up as virtual hosts in a sub folder of the webroot like:

|-wamp_root
  |-www
    |-vhosts
      |-public_site_1
      |-public_site_2

Then you can go back into your httpd.conf and add this below your /wamp/www/ rule:

<Directory "<installation drive>/wamp/www/vhosts/">
    # There will be comments here and some options like FollowSymLinks and AllowOverride
    Order Allow,Deny
    Allow from all
</Directory>

This will allow anything in the www folder to be accessed only locally, and anything in the vhosts sub folder to be accessible outside. Again, remember to restart Apache whenever you change this file.

查看更多
干净又极端
4楼-- · 2019-06-07 09:34

It is not difficult.

  1. edit the index file by notepad++
  2. find the line &projectContents
  3. change from &projectContents to &project---Contents

then the project title disappears.

查看更多
登录 后发表回答