How to reduce 404 errors created by ++liker.profile_URL++

Are you getting lots of 404 errors in the log because of some urls having patterns like ” ++liker.profile_URL++ ” ? How to reduce 404 errors created by ++liker.profile_URL++ ? Here is the solution to stop those 404 errors and convert those urls to result in 301 permanent redirects to your homepage.

Problem:
Some days back, when I saw the log created by Better WP Security plugin installed on my blog, there were a lot of 404 errors because of some weird URLs something like this:

  1. subharanjan.com/subharanjan.com/subharanjan.com/remove-or-override-functions-attached-to-a-specified-filter-hook/++liker.profile_URL++
  2. subharanjan.com/++liker.profile_URL++

I tried to find out about this and seems like this is a link dropping spambot. I am not sure what exactly it does but here is a solution to stop this.

Solution:

  • Open you .htaccess file.
  • Add these lines below into your .htaccess file which can be found at the root of your WordPress installation.

    Add these lines before the lines( url rewrites ) added by WordPress for permalink support. It should look like this:

  • Save the .htaccess file and check by accessing one of the urls having ++liker.profile_URL++ and see if it results in a 404 Page not found error OR simply redirects to your home page.

Explanation of the above htaccess code snippet:
RewriteCond will be looking for the pattern “++liker.profile_URL++” in the requested urls. Once it finds that piece of text in the requested url, it will redirect the request to home page in place of creating a 404 error as mentioned in the RewriteRule section.

RewriteRule defines a particular rule.
The first string of characters after RewriteRule defines what the original URL looks like.
The second string after RewriteRule defines the new URL. This is in relation to the document root (html) directory. / means the html directory itself, and subfolders can also be specified.

  • ^ begins the line to match.
  • . stands for “any non-whitespace character”
  • * means that the previous character can be matched zero or more times.
    So, ^uploads.*$ matches uploads2009, uploads2010, etc.
    ^.*$ means “match anything and everything.” This is useful if you don’t know what your users might type for the URL.
  • () designates which portion to preserve for use again in the $1 variable in the second string. This is useful for handling requests for particular files that should be the same in the old and new versions of the URL.
  • [NC] matches both upper- and lower-case versions of the URL.
  • [R=301,L] – this performs a 301 redirect and also stops any later rewrite rules from affecting this URL. It’s on the same line as RewriteRule, at the end.

Source: https://kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules#gs

6 Comments

  1. Hi,

    I used your snippet but it makes my website go into a 500 error.
    I have this error in my logs :
    RewriteCond: cannot compile regular expression ‘^(.*)++liker.profile_URL++*’

    Do you know why?

    Reply
    • There might be several causes for this 500 error. Make sure: you know what you are doing. Any problem with your .htaccess may make your site down.
      If you can provide me the whole htaccess code, then I can have a look.

      Reply
  2. I’m getting the same error as Doezer. My .htaccess file is quite long, due to W3TC cache rules. I’ve tried pasting the suggested code before W3TC and after, all of which are before the WordPress code.

    Are you sure you want the entire file posted here?

    Reply
  3. Hello,

    I applied the codes to the .htaccess file of the document root folder of my website.

    HOWEVER, after that, I was unable to access the site as admin, yet the site was visible to readers. So, I had to remove the new codes!

    Can you help me figure out the cause of the problem?
    I noticed that unlike the instructions, my .htaccess file has this code
    IfModule mod_rewrite.c
    Could it be the problem?

    Thanx.

    Reply

Leave a Reply