.htaccess for a WordPress website, utilizing a redirect

Following this article: http://premium.wpmudev.org/blog/limit-access-login-page/

I have included the following code in my .htaccess file:

Read More
ErrorDocument 401 /path-to-your-site/index.php?error=404
ErrorDocument 403 /path-to-your-site/index.php?error=404

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{HTTP_REFERER} !^http://(.*)?your-site.com [NC]
RewriteCond %{REQUEST_URI} ^(.*)?wp-login.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteRule ^(.*)$ - [F]
</IfModule>

My website’s URL does include the “www” portion, therefore is it safe/okay to include the “www” for the following line:

RewriteCond %{HTTP_REFERER} !^http://(.*)?www.your-site.com [NC]

I’m not very familiar with editing the .htaccess document, I appreciate any help. Thank you

Related posts

1 comment

  1. To only allow www site your this directive:

    RewriteCond %{HTTP_REFERER} !^https?://www.your-site.com/ [NC]
    

    This will also allow https protocol.

Comments are closed.