Converting a Drupal Site to Straight HTML

Web Development:

When Bad Hosts (Yahoo Small Business) Happen to Good Drupal Sites

Time and again, I work for a client who is stuck with a horrid server environment -- say -- Yahoo Small Business.* Surely you must think that a company like Yahoo -- who employs none other than Rasmus Lerdorf -- would offer a decent environment. That's where you'd be wrong.

Its so bad that Drupal 6 won't even allow itself to ATTEMPT an installation. And with good reason. Consider the facts:

It seems like its not even worth the effort to try to get drupal to run there. Since the site has to be live on monday, I employed a crude method that gathers all URL aliases, and a few more paths, and generates a full tree of directories and index.php files to mirror the pathauto links. Break the glass, and use this in case of emergency. [its best to run this on a local machine, btw -- it takes a while, and you'll want to turn up max page execution time up to near 120 seconds and beyond for most sites in the php.ini files.

// this function will dump the html in a file called "exports" in your files directory
function because_yahoo_hosting_sucks() {
$output = 'test';
$sql = db_query("SELECT dst FROM {url_alias}");
$count = 0;
while($result = db_fetch_object($sql)) {
/// use absolute paths with drupal_http_request
$response = drupal_http_request(url($result->dst, array('absolute' => true)));
// result->data is the actual page
$output .= drupal_to_html($result->dst, $response->data);
$output .= "";
// couple of pages left out of the aliased table
$more = array(
foreach($more as $url) {
$response = drupal_http_request(url($url, array('absolute' => true)));
$output .= drupal_to_html($url, $response->data);
$output .= "";
$output .= "";
// be on the lookout for pages with incorrect paths, and debug at will...
$output .= "wrote ".$count." crappy html files because yahoo sucks...";
print $output;

function drupal_to_html($url, $page) {
// only creates a directory if there's a file for the directory.
// this can be fixed, but only bugged me in 1 or 2 pages.
$path = file_create_path('export/'.$url);
file_check_directory($path, FILE_CREATE_DIRECTORY);
// we add index.php because of pathauto urls
file_save_data($page, $path .'/index.php', FILE_EXISTS_REPLACE);
return $path.'/index.php';

// now weep at your dreamweaver site


  • Clear cache, and turn on css and JS propagation, files/js, files/css to to the same relative path as it is on your drupal install
  • lrn2use version control - it makes dealing with themes, files, and images much easier in this sad scenario


  • Yes, I thought of recommending they switch hosts... they need the site live on monday, and have 80-100 email address on their yahoo domain that can't stop working...
  • Yes, I know you can route mail to one IP, and web traffic to another IP. Guess what? They don't have their own IP.
  • And, they bought the domain using yahoo, so they have no control over it anyhow. Its either all traffic to them, or all traffic somewhere else.