For \(p\in (1,\infty )\) and \(\alpha \in \mathbb {R}\) , we consider measurable functions g on \(\mathbb {S}^{N-1}\) that satisfy the following weighted Hardy inequality: \( \int _{\mathbb {R}^N}\frac{ g (x/|x|)}{|x|^{p+\alpha }}|u(x)|^p dx \le C\int _{\mathbb {R}^N}\frac{|\nabla u(x)|^p}{|x|^\alpha } dx, \quad \forall \,u\in \mathcal {C}_c^\infty (\mathbb {R}^N), \) for some constant \(C>0\) . Depending on N, p, and \(\alpha \) , we identify suitable function spaces for g so that the above inequality holds. The constant obtained is sharp, in the sense that it is sharp when \(g \equiv 1\) . Furthermore, we establish the sharp fractional Hardy inequality with homogeneous weights.