In recent decades, much attention has been focused on the topic of optimal paths in weighted networks due to its broad scientific interest and technological applications. In this work we revisit the problem of the optimal path between two points and focus on the role of the geometry (size and shape) of the embedding lattice, which has received very little attention. This role becomes crucial, for example, in the strong disorder (SD) limit, where the mean length of the optimal path (ℓ[over ¯]_{opt}) for a fixed end-to-end distance r diverges as the lattice size L increases. We propose a unified scaling ansatz for ℓ[over ¯]_{opt} in D-dimensional disordered lattices. Our ansatz introduces two exponents, φ and χ, which respectively characterize the scaling of ℓ[over ¯]_{opt} with r for fixed L, and the scaling of ℓ[over ¯]_{opt} with L for fixed r, both in the SD limit. The ansatz is supported by a comprehensive numerical study of the problem on 2D lattices, yet we also present results in D=3. We show that it unifies well-known results in the strong and weak disorder regimes, including the crossover behavior, but it also reveals novel scaling scenarios not yet addressed. Moreover, it provides relevant insights into the origin of the universal exponents characterizing the scaling of the optimal path in the SD limit. For example, for the fractal dimension of the optimal path in the SD limit, d_{opt}, we find d_{opt}=φ+χ.