Last active
August 8, 2016 19:14
-
-
Save 0x7466/52febcf079f7182bfeb3 to your computer and use it in GitHub Desktop.
SEO friendly root URL in Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
# This isn't the best solution | |
# if you want to get to the | |
# root page and you do I18n, | |
# because it adds a parameter | |
# if you link to the root page. | |
# | |
# FormHelper Example: <%= link_to "Home", root_path %> | |
# Result: http://example.com/?locale=en | |
# | |
# This isn't very SEO friendly. | |
root 'welcome#index' | |
# Better solution | |
# | |
# Example: <%= link_to "Home", i18n_root_path %> | |
# Result: http://example.com/en | |
# | |
# Much SEO friendlier :) | |
get ':locale' => 'welcome#index', as: :i18n_root | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment