In a Rails 2.3 app I have a SitemapController
with a sitemap
action that creates a human-readable sitemap page, and a route to that in the routes file. In the public folder there's a sitemap.xml
file for search engines. The problem is that http://mysite/sitemap
is serving up sitemap.xml
, and not routing to the controller. If I delete sitemap.xml
then it routes to the controller just fine.
On several other very similar sites we have the exact same arrangement, but on those the existence of sitemap.xml
does not prevent Rails from routing to the controller. On those sites, as expected, http://mysite/sitemap
routes to SitemapController#sitemap
and http://mysite/sitemap.xml
serves the static file. Yet I've been unable to discover any difference that could be causing this problem.
Can anyone suggest what might be causing this, or how I might go about debugging it?
This is probably a function of how you're hosting your application. Different web server environments have defaults that can affect this. For instance, Apache will tend to serve a static file at a higher priority than a call to your application, but it can be configured to not serve static files at all if you are using something like Passenger.
The way you alter this is highly dependent on the web server software you are using.
you can do something like :
and delete the xml in /public.
more info : http://apidock.com/rails/ActionController/MimeResponds/respond_to