Based on the Riemann–Liouville fractional derivative, an optimal displacement control strategy for fractional incommensurate mass-spring oscillators has been presented. According to the calculus of variations and the Lagrange multiplier technique, the optimality conditions for the given problem are obtained. Using Shifted Legendre polynomials, the problem of solving differential equations is transformed into the problem of solving a set of algebraic equations. The validity, high efficiency and applicability of the proposed method are demonstrated through the simulation results.