A solution to the standard H2 optimal control problem is presented which is particularly useful in machine and process control applications where the output to be controlled is different from the signal for feedback. The tracking problem is considered where the unmeasured output must follow a given reference trajectory. A feature of the solution is that the algorithm involves a number of Diophantine equations associated with each control function, which provides insight and simpler equations for numerical computations. The results are applicable to both one- and two-degrees-of-freedom controller structures and the unusual two-and-a-half-degrees-of-freedom controller structure. A special dynamic robustness weighting function is introduced so that the feedback loop properties can be improved. The general system model employed enables a much wider class of problems to be tackled than is possible with the usual output feedback control problem.