• Joshi Saveena

    (@blackangelsaveena)


    Hi there,
    I am new in htaccess coding. I was trying to make changes for htaccess files to stop hotlinking and the spam referrals but when i put in the code it results in the 500 error page.
    I am not sure what is wrong but I added the codes in htaccess before #end wordpress line.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    #disable hotlinking of images with forbidden or custom image option
    RewriteEngine on
    # Options +FollowSymlinks
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https://mydomain.com.*$ [NC]
    RewriteRule .*\.(gif|jpg|jpeg|png|bmp)$ [NC, F, L]

    # block referer spam
    RewriteEngine On
    # Options +FollowSymlinks
    RewriteCond %{HTTP_REFERER} server20\.openfrost\.com [NC, OR]
    RewriteCond %{HTTP_REFERER} server12\.openfrost\.com [NC, OR]
    RewriteCond %{HTTP_REFERER} buttons\-for\-website\.com [NC, OR]
    RewriteCond %{HTTP_REFERER} www9\.openfrost\.com [NC, OR]
    RewriteCond %{HTTP_REFERER} semalt\.semalt\.com [NC]
    RewriteRule ^.* – [F,L]

    # END WordPress

    Is it correct or I missed something.
    Also just curious, I don’t know why”” # Options +FollowSymlinks “”is used for??
    A little help would be really great.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Also just curious, I don’t know why”” # Options +FollowSymlinks “”is used for??

    its not its commented out ‘#’ means comment

    ‘FollowSymlinks’ is completely un related to redirects;- it tells apache whether or not to allow “follow” symbolic links which is a type of folder alias on unix file systems.

    First off, avoid adding anything between Begin wp and end wp as wordpress or any plugin might inadvertently delete any of your changes/additions

    Their basically marker so it knows where to edit the file.

    Secondly add your directives one by one that way you can figure out which one is causing the problem.

    so delete this, and the other block

    #disable hotlinking of images with forbidden or custom image option
    RewriteEngine on
    # Options +FollowSymlinks
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^https://mydomain.com.*$ [NC]
    RewriteRule .*\.(gif|jpg|jpeg|png|bmp)$ [NC, F, L]

    try adding this below the end wp

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?PutYourDomainHere.com [NC]
    RewriteRule \.(jpg|jpeg|png|gif|bmp)$ - [NC,F,L]

    Replace ‘PutYourDomainHere.com’ with you actually domain name

    test your site, if its still working then the rules haven’t broke anything

    use this tool to see if you can hotlink an image

    Thread Starter Joshi Saveena

    (@blackangelsaveena)

    Hi Sorry for the bad delayed response.
    I will try your solution and let you know.
    One more question, does RewriteEngine ON goes with all the blocks or is just written once??
    Thanks.

    Hi there, I may be a bit late but maybe this will help…

    I added the following code without any problems at the very top of my .htaccess file with a line space below it…

    #disable hotlinking of images with forbidden or custom image option
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com/myfeedburnername [NC]
    RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

    Notes:

    1. Replace ‘mydomain.com with your domain
    2. Replace myfeedburnername with your domain (I’m not 100% sure this is needed but I was told to use my feedburner name also – go to your Feedburner.com account or create one)

    Hope this helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Order of codes in htaccess file’ is closed to new replies.