Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - how to make page visible only in local network

Tags:

php

.htaccess

lan

Hi i've got another question, i'm writing a simple website in PHP and i have problem with visibility of my website in local network to make it visible to remote addresses i used

$_SERVER['REMOTE_ADDRESS']

, but i want to make it visible in my LAN.

How can i do this ??

like image 565
arclite Avatar asked May 04 '12 20:05

arclite


2 Answers

also in .htaccess you can allow from your ip/subnet, like this:

Order Deny,Allow
Deny from all
Allow from 192.168.1.1/24

of course it should match your LAN

like image 90
evaldasc Avatar answered Sep 23 '22 15:09

evaldasc


You should be doing this in your .htaccess file.

First you specify a Deny All, then specify a list of IP addresses that should be allowed.

order deny,allow
deny from all
allow from X.X.X.X
allow from X.X.X.X
allow from X.X.X.X

You can allow ranges like this:

allow from 10.0.0.0-10.255.255.255
allow from 10.0-255.0-255.0-255
allow from 10.*.*.*

If you want to allow 1.2.3.254, 1.2.3.255, 1.2.4.1, 1.2.4.2, 1.2.4.3, and 1.2.4.4,
you can do it like this:

allow from 1.2.3.254-1.2.4.4
like image 34
Ozzy Avatar answered Sep 24 '22 15:09

Ozzy