How to restrict folders. [Fixed]
Posted by: Karlos (---.wfd79a.dsl.pol.co.uk)
Date: February 21, 2009 12:24PM

Well I got my WAMP server online but I found out that they can view certian projects and overall the main index and i'm wondering if i can block access to them because i have important files which need to be "secured" away from the public.

Edit: Maybe i could put an IP restriction on?



Edited 2 time(s). Last edit at 02/21/2009 12:47PM by Karlos.

Options: ReplyQuote
Re: How to restrict folders.
Posted by: Karlos (---.wfd79a.dsl.pol.co.uk)
Date: February 21, 2009 12:47PM

Fixed i used:

function validip($IP)
{
if (!empty($IP) && ip2long($IP)!= '-1')
{
$ReservedIps = array (
array('0.0.0.0', '2.255.255.255'),
array('10.0.0.0', '10.255.255.255'),
array('127.0.0.0', '127.255.255.255'),
array('169.254.0.0', '169.254.255.255'),
array('172.16.0.0', '172.31.255.255'),
array('192.0.2.0', '192.0.2.255'),
array('192.168.0.0', '192.168.255.255'),
array('255.255.255.0', '255.255.255.255')
);

foreach ($ReservedIps as $R)
{
$Min = ip2long($R['0']);
$Max = ip2long($R['1']);
if ((ip2long($IP) >= $Min) && (ip2long($IP) <= $Max)) return false;
}
return true;
}
else
{
return false;
}
}

function getip()
{
if (validip(isset($_SERVER['HTTP_CLIENT_IP'])))
{
return $_SERVER['HTTP_CLIENT_IP'];
}
foreach (explode(",", isset($_SERVER['HTTP_X_FORWARDED_FOR'])) as $IP)
{
if (validip(trim($IP)))
{
return $IP;
}
}
if (validip(isset($_SERVER['HTTP_X_FORWARDED'])))
{
return $_SERVER['HTTP_X_FORWARDED'];
}
else if (validip(isset($_SERVER['HTTP_FORWARDED_FOR'])))
{
return $_SERVER['HTTP_FORWARDED_FOR'];
}
else if (validip(isset($_SERVER['HTTP_FORWARDED'])))
{
return $_SERVER['HTTP_FORWARDED'];
}
else if (validip(isset($_SERVER['HTTP_X_FORWARDED'])))
{
return $_SERVER['HTTP_X_FORWARDED'];
}
else
{
return $_SERVER['REMOTE_ADDR'];
}
}

if (getip() != 'Developers IP Adress')
{
die();
}

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: yfastud (Moderator)
Date: February 22, 2009 02:52AM

or you can use htaccess to block certain known ip/ip range

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: Karlos (---.wfd79a.dsl.pol.co.uk)
Date: February 22, 2009 11:34AM

WAMP has a .htaccess?
I never noticed that..
Can you direct me to where it is?

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: c2dan (---.sotn.cable.ntl.com)
Date: February 22, 2009 01:25PM

You can create one you're self.

Open notepad and go to Fille > Save As...

Type "C:\wamp\www\.htaccess" (including the quotes) into the filename box and click save. A .htaccess file should now be present within WAMPs WWW folder

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: Karlos (---.wfd79a.dsl.pol.co.uk)
Date: February 22, 2009 03:20PM

Yea I know i can create a .HTACCESS but that involves making a new one from scratch... So is there one already with WAMP?

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: c2dan (---.sotn.cable.ntl.com)
Date: February 22, 2009 05:28PM

Like what? You just have add in the relevant commands. WAMP does not have a preconfigured .htaccess for blocking access to a directory with a given IP range.

For preventing access to a directory have a read of the manual for the commands you'll need
[httpd.apache.org]

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: Karlos (---.wfd79a.dsl.pol.co.uk)
Date: February 22, 2009 07:05PM

I do know Apache..

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: c2dan (---.sotn.cable.ntl.com)
Date: February 22, 2009 07:54PM

So what do you mean by

Karlos Wrote:
-------------------------------------------------------
> Yea I know i can create a .HTACCESS but that
> involves making a new one from scratch... So is
> there one already with WAMP?

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: Karlos (---.wfd79a.dsl.pol.co.uk)
Date: February 23, 2009 07:55PM

All i wanted to know was that if there was a predefined .htaccess

Options: ReplyQuote
Re: How to restrict folders. [Fixed]
Posted by: yfastud (Moderator)
Date: February 24, 2009 11:50PM

to clear your confusion, wamp does not come w/ any predefined .htaccess since it would restrict/allow something that might be one's interested but problem w/ others, so you have to add and customize .htaccess yourself to meet your desire needs ;-)

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote


Sorry, only registered users may post in this forum.