0
votes

My application was built with WordPress. After 4 years I migrated from WordPress to Ruby on Rails 4.2.4.

My google page score is very good and I would like to redirect my WordPress links to my new setup (Ruby on Rails). My Ruby on rails applications link structure is different then WordPress.

PS: I still on same domain

WP Link Structure: my-website.com/year/month/day/Post-Title

Ruby on Rails Link Structure: my-website.com/p/Post-Title

How can I permanently move old links to my new links and have SEO in mind.

I am basically doing this for SEO

1
@Iceman Yeah this would work if the links were not on Wordpress. All the links are outside of the application/controller and its not just one redirect, its about 2000 redirectsRubioli
Hey not used WP in a while, but you should check this plugin: wordpress.org/plugins/safe-redirect-manageroreoluwa
Thanks @oreoluwa These would work if my Wordpress application wouldn't be gone when migrating process was done.Rubioli

1 Answers

1
votes

To redirect from old links structure to another, while keeping only a part of the original URLs, you must capture this part and use it in the target URL

RewriteEngine on
RewriteRule ^.+?/.+?/.+?/(.+)$ /p/$1 [R,L]

The first three .+? match year, month and day. The final (.+) captures the title, so it can be reused in the target URL /p/$1.

When everything works as it should, you may replace R with R=301 (permanent redirect). Never test with R=301.