For the record, I freaking hate what Wordpress Users are doing to the description field in RSS feeds. You don't need to link to the content in the description, there's a field for that in the feed.

  Posted 2 days Ago

Had some tough Drupal 7 deployments to do this evening.  Although things can be a little ore complicated in Drupal 8, I really prefer the built in configuration management.  It certainly makes updates and deployments much easier.

  Posted 4 days Ago

Hosting Separate Websites from the Same Container on Pantheon

I know I've mentioned that I've moved all my sites over to Pantheon running on Drupal 8. I have a number of sites (blog, photography, professional, an about page, and a number of other private sites). Now I don't get a ton of traffic I wanted to find a way to host all my sites out of the same pantheon continuer. This is both to reduce costs and time I spend doing core / contrib updates. I want each site to have it's own look and feel (a separate theme) and live under its own domain.

It occured to me that I could easily organize my content by path (/blog/* for the blog content, /professional/* for the web development content, etc). This can be driven taxonomically using Pahtauto to handle the paths.

As far as having a separate theme for each site is concerned I could use the switch page theme module.  This feels like a replacement for the themekey module from Drupal 7.

Next I thought about how to handle the page redirection.  I looked at my options:

  1. Pantheon doesn't support multisite drupal. Even if they did, I'd still have to perform updates on each site individually.
  2. Domain Access could do this, but feels like overkill. It hasn't always been the most stable of modules and it's a lot of a little.
  3. I could write a custom module to do redirect to the proper domain.

So as I thought about writing a module, I realized that it would be inefficient for Drupal to do a full bootstrap just to redirect and having to start the process again.  So I decided to add the redirects to settings.php.

<?php
$request_uri 
explode('/',$_SERVER['REQUEST_URI']);
        
    if  (isset(
$_ENV['PANTHEON_ENVIRONMENT']) && ($_ENV['PANTHEON_ENVIRONMENT'] == 'live') && ($_SERVER["PATH_TRANSLATED"] <> "/opt/pantheon/drush8/drush.php")){
    
        if ((
$request_uri[1] == "") && ($_SERVER['HTTP_HOST'] == "freelancedrupal.com" ) ){
            
header('HTTP/1.0 301 Moved Permanently');
            
header('Location: https://freelancedrupal.com/professional');
            exit ();    
        }
        
        elseif ((
$request_uri[1] == "professional") && ($_SERVER['HTTP_HOST'] <> "freelancedrupal.com" ) ){
            
header('HTTP/1.0 301 Moved Permanently');
            
header('Location: https://freelancedrupal.com'.$_SERVER['REQUEST_URI']);
            exit ();
        }
        
        elseif ((
$request_uri[1] == "") && ($_SERVER['HTTP_HOST'] == "bowtiesare.cool" ) ){
            
header('HTTP/1.0 301 Moved Permanently');
            
header('Location: https://bowtiesare.cool/blog');
            exit ();
        }
        
        elseif ((
$request_uri[1] == "blog") && ($_SERVER['HTTP_HOST'] <> "bowtiesare.cool" ) ){
            
header('HTTP/1.0 301 Moved Permanently');
            
header('Location: https://bowtiesare.cool'.$_SERVER['REQUEST_URI']);
            exit ();
        }
        
        elseif ((
$request_uri[1] == "") && ($_SERVER['HTTP_HOST'] == "seanreiser.com" ) ){
            
header('HTTP/1.0 301 Moved Permanently');
            
header('Location: https://bowtiesare.cool/sean-reiser');
            exit ();
        }
        
        elseif ((
$request_uri[1] == "sean-reiser") && ($_SERVER['HTTP_HOST'] <> "seanreiser.com" ) ){
            
header('HTTP/1.0 301 Moved Permanently');
            
header('Location: https://seanreiser.com'.$_SERVER['REQUEST_URI']);
            exit ();
        }

}
?>

The code is rather simple. There's a pair of if's for each domain, one to redirect the root of the domain to the right path, the other to redirect to the proper domain. The bit about drush is rather important if you're on pantheon. If you're useing terminus to run drush (or their interface to clear cache), the redirect will screw things up.

The only downside to this approach is that you wind up with the subdirectory in the URL after the redirect, but I willing to accept that to get things working.

  Posted 4 days Ago