We investigate an exact solution that describes the embedding of the four-dimensional (4D) perfect fluid in a five-dimensional (5D) Einstein spacetime. The effective metric of the 4D perfect fluid as a hypersurface with induced matter is equivalent to the Robertson-Walker metric of cosmology. This general solution shows interconnections among many 5D solutions, such as the solution in the braneworld scenario and the topological black hole with cosmological constant. If the 5D cosmological constant is positive, the metric periodically depends on the extra dimension. Thus we can compactify the extra dimension on $S^1$ and study the phenomenological issues. We also generalize the metric ansatz to the higher-dimensional case, in which the 4D part of the Einstein equations can be reduced to a linear equation.