0

I have a (potentially huge) problem that I did not anticipate. I just built a beautiful new site for the organization I work for. It is a massive improvement over the previous site. The site is also, I'd say, larger than average.

The previous site utilized query strings to navigate around the site, and in a really awful, highly customized fashion. Basically all page URLs looked something like /index.php?page=/path/to/page.php&stuff=4|5|3|1.

The new site utilizes clean URLs.

Now the problem. Crawlers from all over are rampaging through the site and causing high CPU utilization (~50% at all times). I have caching enabled as well as JavaScript and CSS aggregation.

Here's an example URI from the access log:

/?p=1%7C26%7C31%7C33%7C2%7C7&page=publications.php

In the current scheme that should just return a 404 in my opinion because that literally represents nothing. Instead it's returning 200 OK which is wrong in so many ways, but technically is right because you do in fact get the home page back. In fact, every single "page" that the crawlers look at right now 90% of the time it's getting back the homepage because it's either looking at /index.php?querystring or /?querystring where of course Drupal does nothing with the query string and just returns the homepage!

I'm not entirely sure how to communicate the correct HTTP status codes to the crawlers. Any advice is much appreciated at this time. I now understand why Google implores you to build sites with clean URL schemes...

1
  • While I think it's a worthwhile question, and I agree with MPD's answer, do it in httpd config instead of code, I suggest you put up varnish before you server if it's a big site. That has the potential to drop your CPU utilization to the bottom.
    – Letharion
    Commented Mar 23, 2012 at 18:05

1 Answer 1

1

You need to handle this in your httpd.conf or .htaccess before Drupal handles it.

Your best bet is to come up with some rewrite rules and 410 Gone them. Something like this

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} page=(\w+)&stuff=(\w+)  
RewriteRule ^(.*)$ - [G,L]

should be a start. You need to play with the query string to match the inbound requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.