2013-08-29 33 views
0

我在我的應用程序如何改變鏈接到更多的搜索引擎友好的軌道

http://localhost:3000/lv/manufacturer_products?manufacturer=Komptech

http://localhost:3000/en/products?category=Shredders 

這樣的聯繫,但我的朋友說,這些鏈接不搜索引擎友好,謂我要改變他們,到

http://localhost:3000/en/manufacturer_products/Komptech 

或similair這個

http://localhost:3000/en/products/category/Shredders 

但是,我怎樣才能真正改變結構的鏈接沒有幫助任何寶石?使用路線?

感謝名單

+0

沒錯,你猜對了 - 航線 – roninblade

+0

多種方式公用文件夾HTTP添加的robots.txt:// tools.seobook.com/robots-txt/ – 2013-08-29 08:20:46

回答

1

請參閱文檔namespaces以及SO上的this answer

你甚至可以只做指定的路線。是這樣的:

resources :products do 
    resources :manufacturers 
end 

這對於manufacturers索引操作將返回此:

product_manufacturers GET /products/:product_id/manufacturers(.:format)   manufacturers#index 

,然後你可以在路線寫。RB

match '/:id/products/:name', 
    :to => 'manufacturers#index', :as => :manufacturers 

,當你把它

<%= link_to @manufacturer.name, manufacturers_path({id: @manufacturer.product_id, name: @manufacturer.name}) %>

這將使http://localhost:3000/x/products/Komptech

+0

tnx我接受了您的答案:) – Edgars

0

我不能限制我分享這個......有一次,我得到了一個很好的幫助優化我的網站的搜索引擎優化

的面貌邁向鏈接

http://complitech.net/seo-basics-high-benifit-for-ruby-on-rails-developer/

看第三點得到你的答案網址

3)提高您的網址

的結構一般是在老款的網址是非結構化的,而不是目錄明智的,這樣會讓你的網址是結構化。

例如:

www.herrybaseballcards.com/images/baseball/top-ten-baseballcards.html

所以在路線

match '/:foldername/:products/:name', :to => 'products#index', :as => :products

所以忽視基於查詢的URL結構