Motility is often a pathogenicity determinant of bacteria targeting mucosal tissues. Flagella constitute the machinery that propels bacteria into appropriate niches. Besides motility, the structural component, flagellin, which forms the flagella, targets Toll-like receptor 5 (TLR5) to activate innate immunity. The compartmentalization of flagellin-mediated immunity and the contribution of epithelial cells and dendritic cells in detecting flagellin within luminal and basal sides are highlighted here, respectively. While a direct stimulation of the epithelium mainly results in recruitment of immune cells and production of antimicrobial molecules, TLR5 engagement on parenchymal dendritic cells can contribute to the stimulation of innate lymphocytes such as type 3 innate lymphoid cells, as well as T helper cells. This review, therefore, illustrates how the innate and adaptive immunity to flagellin are differentially regulated by the epithelium and the dendritic cells in response to pathogens that either colonize or invade mucosa.