Support » Fixing WordPress » 404 not being returned on garbage urls

  • This driving me nutty.
    In my logs I’m seeing garbage queries appended to my domain. Worse, they’re showing in Google & Yahoo SERP’s. An example of some of the requests in my log.

    GET /?query=es_desp.php/es_custom_menu&command=search

    GET /?page=92%2520%2520//program/modules/mods_full/shopping_cart/includes/login.php%3f_SESSION%255Bdocroot_path%255D=

    GET /?view=page&pagename=

    My htaccess is:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) – [F,L]

    But it never shows a 404 for any of these garbage urls, which I understood it would if a file or dir didn’t exist. It displays the home page (not static) with the full request uri in the address bar.

    To stop some of the garbage I added the following to htaccess

    RewriteCond %{HTTP_user_agent} ^Mozilla/5\.0$ [OR]
    RewriteCond %{HTTP_user_agent} ^libwww-perl/5\..*$ [OR]
    RewriteCond %{HTTP_user_agent} ^curl/.*$ [OR]
    RewriteCond %{HTTP_user_agent} ^-$ [OR]
    RewriteCond %{HTTP_REFERER} ^-$
    RewriteRule (.*) – [F,L]

    That works, but instead of a 404 which it should show, it displays a 500. The theme has a 404.php, so it’s not an issue of a missing 404 page.
    Thinking it may be the blog, I installed a bog standard blog on another domain (same server), but it gives the same results as above. Am I missing something here?

  • The topic ‘404 not being returned on garbage urls’ is closed to new replies.