Fixed and moving boundary problems for the one-dimensional heat equation are considered. A unified approach to solving such problems is proposed by embedding a given initialboundary value problem into an appropriate initial value problem on the real line with arbitrary but given functions, whose solution is known. These arbitrary functions are determined by imposing that the solution of the initial value problem satisfies the given boundary conditions. Exact analytical solutions of some moving boundary problems that have not been previously obtained are provided. Moreover, examples of fixed boundary problems over semi-infinite and bounded intervals are given, thus providing an alternative approach to the usual methods of solution.