2013-02-01 17 views
0

我試圖創建我的應用程序使用sitemap_generator gem.子域但是,我得到一個錯誤,我的代碼那裏設有一個站點地圖:軌道/ Sitemap_Generator:二級域名的站點地圖

the scheme http does not accept registry part: .foo.com (or bad hostname?)

我的地圖。 rb:

SitemapGenerator::Sitemap.default_host = "http://www.foo.com" 
SitemapGenerator::Sitemap.sitemaps_host = "http://s3.amazonaws.com/foo/" 
SitemapGenerator::Sitemap.public_path = 'tmp/' 
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/' 
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new 

SitemapGenerator::Sitemap.create do 
    add '/home' 
end 

Customer.find_each do |customer| 
    SitemapGenerator::Sitemap.default_host = "http://#{customer.user_name}.foo.com" 
    SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/#{customer.user_name}" 
    SitemapGenerator::Sitemap.create do 
    add '/home' 
    end 
end 

我在做什麼錯?

回答

1

我是這個寶石的作者。

我相當確定問題出在一個客戶用戶名中包含一個URL中不允許的字符。一個簡單的測試與簡單名稱的作品例如:

%w(bill mary bob).each do |customer| 
    SitemapGenerator::Sitemap.default_host = "http://#{customer}.foo.com" 
    SitemapGenerator::Sitemap.sitemaps_path = "sitemaps/#{customer}" 
    SitemapGenerator::Sitemap.create do 
    add '/home' 
    end 
end 
+0

看看[文檔](https://github.com/kjvarga/sitemap_generator#generating-multiple-sitemaps)。這幫了我很多! – Hiasinho

相關問題