Rails.application.routes.draw do |map| match "/:year/:month/:day/:id" => "posts#show", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ } match "/:year(/:month(/:day))" => "posts#index", :constraints => { :year => /\d{4}/, :month => /\d{2}/, :day => /\d{2}/ } match "/tag/:id" => 'posts#tag' resources :posts root :to => "posts#index" end