We consider the problem of designing distributed controllers for a class of systems which can be obtained from the interconnection of a number of identical subsystems. If the state space matrices of these systems satisfy a certain structural property, then it is possible to derive a procedure for designing a distributed controller which has the same interconnection pattern as the plant. This procedure is basically a multiobjective optimization under linear matrix inequality constraints, with system norms as performance indices. The explicit expressions for computing these controllers are given for both Hinfin or H2 performance, and both for static state feedback and dynamic output feedback (in discrete time). At the end of the paper, two application examples illustrate the effectiveness of the approach.