title: Rails /sitemap.xml redirects to root
body: <p>I'm using dynamic_sitemaps gem for generatig sitemap.
  <a href="https://github.com/lassebunk/dynamic_sitemaps" rel="nofollow">https://github.com/lassebunk/dynamic_sitemaps</a></p>
  
  <p>Locally, when I try to go localhost/sitemap.xml it displays the sitemap file.</p>
  
  <p>When I try this in production on a vps it doesn't work and just redirects me to root_path.</p>
  
  <p>If I cd to public/sitemaps/ I can see the sitemap.xml(it exists).</p>
  
  <p><strong>What can be wrong here?</strong></p>
  
  <p>here's my <strong>routes.rb</strong></p>
  
  <pre><code>Rails.application.routes.draw do
    .....
  
    get 'sitemap' =&gt; 'home#sitemap', format: :xml
    get 'robots' =&gt; 'home#robots', format: :text#, defaults: { format: :text }
    get '*path', to: 'application#handle_404'
  end
  </code></pre>
  
  <p>I've tried to remove <code>format: :xml</code> but it didn't work</p>
  
  <p>/robots.txt works fine.</p>
  
  <p>here's my sitemap meth from home controller</p>
  
  <pre><code>  def sitemap
      respond_to do |format|
        format.xml { render file: 'public/sitemaps/sitemap.xml' }
        format.html { redirect_to root_url }
      end
    end
  </code></pre>
  
  <p>handle_404 in application controller</p>
  
  <pre><code>  def handle_404
      redirect_to root_path
    end
  </code></pre>