Reputation: 1364
I have the sitemap of www.mysite.com hosted on https://s3.amazonaws.com/mysite/sitemaps/sitemap1.xml.gz
Is it possible to configure Rails (routes, controllers, ...) to render the file sitemap1.xml under www.mysite.com/sitemap1.xml.gz?
Thanks.
Ps. the reason why the sitemap is under AWS is this: https://github.com/kjvarga/sitemap_generator/wiki/Generate-Sitemaps-on-read-only-filesystems-like-Heroku
Upvotes: 6
Views: 2101
Reputation: 1043
based on https://github.com/kjvarga/sitemap_generator/issues/173
I'm trying this...
in routes.rb
get 'sitemap(:id).:format.:compression' => 'sitemap#show'
in sitemap_controller.rb
class SitemapController < ApplicationController
def show
data = open("http://{ENV['AWS_BUCKET_PROD']}.s3.amazonaws.com/sitemaps/sitemap#{params[:id]}.xml.gz")
send_data data.read, :type => data.content_type
end
end
Also make sure that sitemap (index) file contains links to other sitemap files (sitemap1, sitemap2...) located at your site and not amazon.
Upvotes: 3
Reputation: 32715
As I understand it, you are deploying to a read-only filesystem such as Heroku.
If so, here are some articles that will help:
Upvotes: 0
Reputation: 13593
Create a controller that would redirect to Amazon S3 file location and create a matching route for it.
routes.rb:
match 'sitemap1.xml.gz' => 'site_map#redirect'
site_map_controller.b:
class SiteMapController < ApplicationController
def redirect
redirect_to 'https://s3.amazonaws.com/mysite/sitemaps/sitemap1.xml.gz'
end
end
Upvotes: 0