Analytical expressions for the flow field as well as for the effective slip length of a shear flow over a surface with periodic rectangular grooves are derived. The primary fluid is in the Cassie state with the grooves being filled with a secondary immiscible fluid. The coupling of the two fluids is reflected in a locally varying slip distribution along the fluid–fluid interface, which models the effect of the secondary fluid on the outer flow. The obtained closed-form analytical expressions for the flow field and effective slip length of the primary fluid explicitly contain the influence of the viscosities of the two fluids as well as the magnitude of the local slip, which is a function of the surface geometry. They agree well with results from numerical computations of the full geometry. The analytical expressions allow an investigation of the influence of the viscous stresses inside the secondary fluid for arbitrary geometries of the rectangular grooves. For classic superhydrophobic surfaces, the deviations in the effective slip length compared to the case of inviscid gas flow are pointed out. Another important finding with respect to an accurate modelling of flow over microstructured surfaces is that not only the effective slip length, but also the local slip length of a grooved surface, is anisotropic.