We currently have a page that has this url: /tires?product_subtype=8
. The page content is a tires list filtered by a specific product subtype. For SEO purposes, we also need the page to be accessible via this url: /lawn-and-garden
.
Is there an easy way to do this? We’re using Ruby on Rails framework and Nginx.
We will be doing this on lots of pages:
/tires?product_subtype=1 - /industrial-tires
/tires?product_subtype=2 - /commercial-tires
etc...
2
Answers
If both the routes are performing the same task then route them to the same
controller#action
inconfig/routes.rb
.For example:
UPDATE:
If I understand you right, then you would like the page to be accessible by both routes
/tires?product_subtype=1
as well as/industrial-tires
(without query param). We have done something similar on one of our projects, we call these pretty url’s as landing pages. I can think of two options to implement these landing pages:If you have a fixed number of very few landing pages:
create an action for each of them which renders corresponding subtype view.
If you have many/ variable number of landing pages:
you will have to create a low priority catch all route and within the mapped action conditionally render specific view based on the slug.
I’d suggest you route your various categories to a single CategoriesController and create an action for each category.
Repeat for other URLs.