I'm working on a Ruby on Rails app where my routes can properly handle something like http://localhost:3000/CA
to go to some page about California. It handles lower case "ca" but is there a way such that if my user manually types in lower case "ca", the URL/Routes will display capital "CA"?
If user request for http://localhost:3000/ca
it should redirect to (301 redirect) http://localhost:3000/CA
,
That you can handle in your controller
def controller_name
if(params[:id].to_s != params[:id].to_s.upcase)
redirect_to urlname_url(:params[:url].to_s.upcase), :status => :moved_permanently
end
# rest of the code
end
It is good to have unique urls as duplicate urls have negative impact on SEO.