Abstract. In this paper, we combine query rewriting and configuration to provide a new semantic-based approach to service composition, featuring a two-stage process that relies on 1) a simple formalization of semantic Web services that supports query rewriting, and 2) a clear separation between constraints and service/domain knowledge description. Given a user query and a set of service descriptions, query rewriting is used to decompose the query into sets of services that implement the required functionalities (discovery phase). At the orchestration phase, configuration is used to capture dependencies between services, and to generate a set of composite Web services ranked according to user preferences, while maintaining validity with respect to business rules organized into different levels (composition, service and user). We provide a formal framework and a complete implementation of the proposed approach, together with experiments by considering services from different domains.