Handing Legacy Static Sites with Kinsta

On occasion I need to host a PHP static website. This is typically while the customer is working on a new WordPress site and simply needs to keep their legacy site live until the new one replaces it. A good option for handling these sites would be to host with a cheap MediaTemple GRID account. This past week I explored using Kinsta, my go-to WordPress web host, to handle these static sites. Here is what I learned.

Kinsta allows new sites to be created without WordPress.

This is a great option if you want to uploading some static files on one environment while developing a new WordPress site in the other environment.

WordPress web host providers treat index.php differently.

Regular host providers will simply deliver whichever .php or .html file that is requested. With WordPress, web servers are configured to fail back to the main index.php should the request fail. In order to work well with static sites, a bit of logic is needed to be added to the top of the main index.php file. The following code will check to see if the page / was called directly. If not it passes the request to a custom 404.php file.

<?php
if ( $_SERVER['REQUEST_URI'] != "/" ) {
        include( '404.php' );
        return;
}

Be sure that the 404.php file begins by declaring a 404 response code.

<?php
header("HTTP/1.0 404 Not Found");

Without this bit of logic, any request to a resource that doesn’t actually exist would return the homepage. Again this makes sense if considering you want bad requests to be handled by WordPress, however, for dumb static files, that’s most likely not something you want.

Kinsta SSL and Force SSL work well with static websites. 👍

You do need to make sure all URL references within the files use https instead of http. That can be handled over SSH with a few clever commands. Other then that, the out of box Kinsta SSL tools work just as you’d expect them.

Conclusion, Kinsta handles static sites just fine. 👌

While a WordPress host is not really optimized for handling static website, it works just fine. Good enough, in fact, that I’ll most likely just use Kinsta next time I need to handle a legacy static site for a WordPress customer.