I’m currently using freindly_id gem in a rails application to slug URLs and make them look nice. So rather than the URL #root/cities/1234 they are #root/cities/#cityname
We are looking to change the cityname part of the URL to something else and it seems as direct as changing the slug in the database to simply read something else, however, someone has suggested we must use a 301 redirect in order to maintain the SEO we have acquired thus far.
Can anyone tell me if there is an impact in changing the URL with the slug, as from my perspective it would seem that the URL is essentially not really changing, e.g. the underlying URL remains /cities/1234
2
Answers
I wouldn’t do it directly in the database. If you use friendly_ids history feature you can do a redirect in your rails controller if it’s using an outdated slug.
From the documentation:
The above answer works when you don’t have pagination on you’re page.
Sometimes you have to use pagination and then the answer from above will always send the user back to the first page of the model. If you have to do this I think it’s maybe better to compare you’re id with the slug of you’re model like this:
This way the user redirects to the correct paginated page