How To Make A Page Accessible By Two Urls For Seo Purposes?
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:
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...
If both the routes are performing the same task then route them to the same
get 'tires', to: 'welcome#index' get 'lawn-and-garden', to: 'welcome#index'
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.
def industrial_tires ## render view filtered for product_subtype = 1 end def commercial_tires ## render view filtered for product_subtype = 2 end ## .... so on
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.
get '*path', to: 'tires#landing_page' ## in routes.rb at the end of the file def landing_page ## "path" would be equal to industrial-tires or commercial-tires, etc. ## conditionally specify view filtered for product_subtype based on path value end
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?