We consider solitary waves propagating on the interface between two fluids, each of constant density, for the case when the upper fluid is bounded above by a rigid horizontal plane, but the lower fluid has a variable depth. It is well-known that in this situation, the solitary waves can be described by a variable-coefficient Korteweg-de Vries equation. Here we reconsider the derivation of this equation and present a formulation which preserves the Hamiltonian structure of the underlying system. The result is a new variable-coefficient Korteweg-de Vries equation, which conserves energy to a higher order than the more conventional well-known equation. The new equation is used to describe the transformation of an interfacial solitary wave which propagates into a region of decreasing depth.