Welcome to WebmasterWorld Guest from 54.198.221.13

Forum Moderators: Ocean10000 & incrediBILL & phranque

Attempts to use .htaccess file to block IP addresses brings down site

.htaccess file preventing access to my site completely

     
1:11 am on Oct 4, 2017 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 27, 2004
posts: 164
votes: 0


I used the .htaccess generator tool. This is what was generated:

Order Deny,Allow
Deny from xxx.xxx.xxx.xx
Deny from xxx.xxx.xxx.xx
Deny from xxx.xxx.xxx.xx

Uploaded the file and it took my entire site off-line

What am I doing wrong? Other than that, the file is empty.

[edited by: phranque at 2:29 am (utc) on Oct 4, 2017]
[edit reason] fixed typo [/edit]

2:29 am on Oct 4, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:10103
votes: 550


What am I do wrong?
Well since you didn't identify who is "allowed" then that's why your site crashed... (that and the regex is broke.)

Try adding
Allow from all
2:38 am on Oct 4, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11076
votes: 106


when all else fails check your server error log file.
4:27 am on Oct 4, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14255
votes: 551


Well since you didn't identify who is "allowed" then that's why your site crashed...

I'm not so sure. I fiddled around on my test site and the server doesn't seem to give a squat if an Allow and/or Deny line is omitted. After all, the whole point of the "Order" directive is that it determines what happens when a request matches either both ("Allow from 11.22.33" and "Deny from 11.22.33" in the same scope) or neither.

Now, the server will throw a fit if the IP given in
Deny from xxx.xxx.xxx.xx
happens to be invalid--for example if one of the segments is > 255. (It doesn't seem to care about trailing spaces in this specific context, though it may well cause disaster elsewhere.)
5:33 am on Oct 4, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:7878
votes: 547


Did the generator tool keep all OTHER directives in the working htaccess or delete them?
5:47 am on Oct 4, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:10103
votes: 550


@tangor - OP had said there is nothing else in the htaccess file, but that got edited.

@lucy24 - even though Apache will tolerate some incomplete regex directives, the config may not. We know nothing about the server set-up hermosa has the account at. Maybe he needed a wrapper?
12:00 pm on Oct 4, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:7878
votes: 547


If there's nothing in .htaccess there should be no .htaccess at all. Valid question if a generator tool made changes that changed something else. If a CMS is involved pretty sure there's OTHER things in .htaccess. ... the "but that got edited:" means what? Typo, or .... what?
5:04 pm on Oct 4, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14255
votes: 551


some incomplete regex directives
Was something edited out of the initial post before I saw it? I see neither a Regular Expression nor a wrapper. The argument in a Deny or Allow line isn't a regex, the way it would be in mod_setenvif.

If your htaccess contains only one line, that one line might well be
Options -Indexes
to override a server-wide setting for auto-indexing (common in shared hosting).
7:20 pm on Oct 4, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:10103
votes: 550


@tangor/lucy - No, none of that
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members