Posts: 3
Threads: 1
Joined: Mar 2014
Okay I'm a total noob when it comes to getsimple, so please bear that in mind. I was wondering if there was anyway in which I could block a certain ip address from accessing my website, or if I could block out all ip addresses except for my own. And if there is could you say how it is done (again I'm a total noob) Thanks
Posts: 6,266
Threads: 181
Joined: Sep 2011
You can put this in a .htaccess file in /admin
but with your ip
Code:
order deny,allow
deny from all
allow from 127.0.0.1
Posts: 3
Threads: 1
Joined: Mar 2014
Thanks a lot, you really helped
(2014-03-10, 23:44:14)shawn_a Wrote: You can put this in a .htaccess file in /admin
but with your ip
Code:
order deny,allow
deny from all
allow from 127.0.0.1
Posts: 6,266
Threads: 181
Joined: Sep 2011
afaik there is not a plugin or anything specific to gs for this, but that is what I use, if you use something other than apache you will of course need some other way.
Posts: 3
Threads: 1
Joined: Mar 2014
I did it but now even I can't access the website (I did use my own ip) and when I delete the.htacces file I still can't access the website. HELP!
Posts: 6,266
Threads: 181
Joined: Sep 2011
What version of apache are you on ?
Also you sure it was successfully deleted ?
Where did you put it?
Posts: 104
Threads: 6
Joined: Aug 2013
Maybe it should be
Code:
order allow,deny
allow from all
deny from xxx.xxx.xxx.xxx
Where xxx.xxx.xxx.xxx the IP should be written that u wanna ban.
Posts: 346
Threads: 27
Joined: Sep 2010
Wrote up a little plugin to try automating what shawn said, except this is strictly for denying access to the given IPs; 1 per line. Does it in any way do the job for you? (if there are any problems, deactivate the plugin and delete the .htaccess file from /admin)
blockip.php (Size: 1.37 KB / Downloads: 4)
Posts: 6,266
Threads: 181
Joined: Sep 2011
Denying? Is it at least a pattern of some sort? Why would you want to deny specific ips?
Also is this for back end only or frontend?
I imagine you would want deny specific on front and allow specific on back, they are kind of reversed roles
Posts: 346
Threads: 27
Joined: Sep 2010
It can easily be modified to allow only those IPs instead.
To deny front-end scripts, would the IPs need to be appended to the .htaccess in the root?
Posts: 6,266
Threads: 181
Joined: Sep 2011
Well if you are making this a plugin then I would just use the first hook available and
$_SERVER["REMOTE_ADDR"] and match a pattern in php.
Posts: 346
Threads: 27
Joined: Sep 2010
Oh fair enough. So just store the list of IP addresses in either a text or xml file and compare it to that, then exit the PHP script immediately if it matches one of the IPs. I wondered if the htaccess method was in some way more elegant (since I've used the previous method on CUsers before), but that seems to work. I'll code it soon.
Also, when you say match a pattern, are you saying that the IP addresses stored by this plugin should allow for wildcards too?
Posts: 6,266
Threads: 181
Joined: Sep 2011
Of course htaccess is better, it stops at the request level, but a plugin would always work as opposed to sometimes.
Yeah wildcards are handy for subnets.
how were you doing it modifying the htaccess directly?