1

Currently I'm able to put WAMP online and access all my projects from other devices using the host IP address.

But what displeases me is the fact that even from other devices, the server's index file which shows the list of all the projects is also accessible. What I want is to be only able to view it from local machine, not from others. Others can only access the index files found in the projects not the one on the root server.

I have tried to set some values in httpd.conf files. But not successful. I searched for this issue on the net, but found different ones.

  • 1
    What "server's index file" are you referring to? "I have tried to set some values in httpd.conf files." - what "values" did you try to set? – MrWhite May 15 '18 at 0:17
  • @MrWhite The OP does not have an index.html file and is getting the index web server function which lists directories and files within the web root. – closetnoc May 15 '18 at 0:56
  • What version of WAMP are you using? I understand there are big differences in how the project list works between versions 2 and 3: stackoverflow.com/questions/23665064/…? – Stephen Ostermiller May 15 '18 at 9:50
  • A website usually has a default index.html or index.php. it is the case for WAMP server which has an inde.php file that displays info, config links and a list of projects. It load when you enter eg. localhost:8080, now it is OK when I can view that file from server machine but I don't want it to be viewed from other machines in the network if they enter the IP of the server. – Francis Nduba Numbi May 15 '18 at 21:14
  • Which version of Apache are you using? – MrWhite May 16 '18 at 0:55
1

the server's index file which shows the list of all the projects is also accessible. What I want is to be only able to view it from local machine, not from others. Others can only access the index files found in the projects not the one on the root server.

From your comments, it would seem you are referring to the physical file index.php residing in the document root of the site (as opposed to an auto generated directory index). However, you want to permit public access to index.php files located in subdirectories (projects?).

You can do this in a number of ways, depending on your specific config and Apache version. I assume you are editing the main server config or relevant VirtualHost container.

One way is to use mod_rewrite. For example:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} "!=203.0.113.111"
RewriteRule ^/(index\.php)?$ - [F]

Where 203.0.113.111 is whatever your local IP address is (or whatever IP address you are accessing the site from).

This will serve a 403 Forbidden for all other users trying to access index.php in the document root only.

  • Thanks. I will try that. But the local IP address! Has it got to be hard coded? What if it isn't a static IP? – Francis Nduba Numbi May 17 '18 at 22:27
  • Is there just a single "local machine", or any machine on the local network? You could perhaps allow all IP addresses on the local IP address range, eg. those addresses that start 192.168.0. (for example)? When you access the web server from the local network, then presumably you are using the local IP address for that server? Is the server's local IP address static, or at least on a fixed local IP address range? Users not on the local network are presumably using the external IP address of your network, which is forwarded to the local IP address? – MrWhite May 17 '18 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.