0
votes

I'm quite new with htaccess, so I'd require some light here.

I set a new site with Wordpress and want to redirect my old Tumblr posts to the ones I imported to Wordpress.

Domain structure is as follows:

Old Tumblr: tumblr.domain.com

New Wordpress: www.domain.com

And the post structure is:

Old Tumblr: tumblr.domain.com/post/numberID/post-title

New Wordpress: www.domain.com/post-title

I made my research and I don't know why, by some reason I'm just having 404.

What I thought was my best bet was this:

RewriteCond %{HTTP_HOST} ^tumblr.domain.com/post/(.*?)/(.*?)$
RewriteRule http://www.domain.com/$2 [R=301,L]

But doesn't work, I only have a 404.

Note: I also see my home (www.domain.com) when entering tumblr.domain.com

Any help would be very apreciated. Thanks in advance.

1
Ok, done, thank you.juansaman

1 Answers

1
votes

Never mind, solved myself, I had to rebuild my htaccess due some addiotional problems I found. Anyway, for anyone trying to redirect tumblr posts from a subdomain to it's main domain, this is how I made it:

First, 301 from subdomain to domain:

RewriteCond %{HTTP_HOST} ^tumblr\.domain\.com [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]

And then, 301 from tumblr posts to imported posts:

RewriteRule ^(.*) http://www.domain.com$1 [L,R=301]
RewriteRule ^/?post/([0-9]+).(.*?)$ http://www.domain.com/$2 [L,R=301]

For some cases, I renamed some posts in my new site, so it won't work for those. I had to redirect manually for those posts, so I had to add the following line after the lines above:

RewriteRule ^old-post-title http://www.domain.com/new-post-title/ [R=301,L]

Hope this works for someone in the same situation.