• maliq

    (@maliq)


    Hi:

    After enabling permalink on my blog, WordPress automatically created a .htaccess file in the site’s root directory. Everything was working properly. Recently, I had to deal with some unfriendly visitors to my blog whom I’d like to ban from my site using .htaccess.

    I downloaded the original htaccess file which looked like this
    —-
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress
    —-

    and added the following lines after “# END WordPress.”
    —-
    order allow,deny
    deny from IP
    deny from IP
    allow from all
    —-

    After reuploading the modified htaccess file, I got an Internal Server Error and couldn’t access my blog anymore. I had to delete the htaccess file per ftp and re-activated permalink.

    Any idea how I can include the ban codes in the htaccess file without causing a server error?

Viewing 8 replies - 1 through 8 (of 8 total)
  • DianeV

    (@dianev)

    I’m not sure about your coding. Is it set up like this?

    <Files .htaccess>
    Order Deny,Allow
    Deny from all
    </Files>

    And is the “IP” replaced by an actual IP address?

    Thread Starter maliq

    (@maliq)

    >I’m not sure about your coding. Is it set up like this?
    [code]

    Oh, I didn't include the <Files .htaccess>-tag? Could that be the problem?

    >And is the "IP" replaced by an actual IP address?

    Yes.

    Thread Starter maliq

    (@maliq)

    Just tried it out with the tag. Same problem. 🙁

    DianeV

    (@dianev)

    > Oh, I didn’t include the <Files .htaccess>-tag? Could that be the problem?

    Absolutely; you have to “open” and “close” that section with the tags.

    Try taking out the IP address lines.

    evilbeet

    (@evilbeet)

    Hey Maliq,

    Do you want to ban them from viewing or just ban them from commenting?

    If you just want to ban them from commenting, blacklist their IPs under Options->Discussion. Much easier than messing with .htaccess, plus you can still get their page views.

    If you want to ban them even from viewing, read this:

    http://lorelle.wordpress.com/2007/09/20/the-easiest-way-to-ban-a-wordpress-spammer/

    And use this:

    http://tools.dynamicdrive.com/userban/

    Thread Starter maliq

    (@maliq)

    Hi:

    Thanks very much for the replies. After doing some googling on my own I found another possibilty: http://lesterchan.net/wordpress/readme/wp-ban.html

    It’s a nifty plug-in that offers pretty much everything I needed and the best thing is you don’t have to screw with the .htaccess file. 🙂

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    This should work fine.

    <IfModule mod_access.c>
    Order Allow,Deny
    Deny from IP
    Allow from All
    </IfModule>

    The ifmodule protect you from errors if the mod_access is not enabled.

    If you still get 500 errors, then your host has broken something. Talk to them about it.

    I agree, something was missing in your code. The directives are often enclosed with the <Directory> tag in your httpd.conf. When talking about the .htaccess file, they are often enclosed with <FilesMatch> tag.

    See here for the correct syntax: Order allow,deny

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘.htaccess problem’ is closed to new replies.