Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Redirect only blog post links from old site to new? WordPress

Hi, I have two sites which are both running WordPress. Site #1 used to have a blog section, but I've moved the blog over to Site #2.

I'm trying to redirect the old blog post links from site #1 to site #2, but I'm having trouble getting this to work, because it's not a universal redirect: it needs to be specifically for blog posts only.

So should not redirect to, but should redirect to

If there's a way to do this, I'd appreciate the help. Thanks!

Answers (5)


Jerson Baguio answers:

You can do that via .htaccess make sure you back up your htaccess so you can revert if everything goes wrong.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule (.*)$$1 [R=301,L]

shoshanna comments:

Will that redirect only blog posts, or all the pages on the site? I need to redirect just the blog section.


Maor Barazany answers:

Assuming that all of your posts' permalinks are with structure that begins with 4 digits of the year, you may use this .htacces rules.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/\d{4}/
RewriteRule (.*)$$1 [R=301,L]

Make sure you put these lines in the beginning of the file, <strong>before</strong> the #BEGIN WordPress section.

The code @Jerson Baguio wrote will redirect all pages on the site.

Maor Barazany comments:

@Alfonso's suggestion is not a best practice to handle this, and also, if it will do the change, it won't help you for future posts but only for already published. It may also create some other issues and not so recommended.


Albert Shala answers:

I would recomend you check out this plugin [[LINK href=""]][[/LINK]] if you are not comfortable editing an htaccess file.


Alfonso Abarca Alvarez answers:

Hi !

for your problem can run the following queries in the database

just have to <strong>change the url and the prefix of the tables in the database (wp_)</strong>

update wp_posts set post_content = replace(post_content, '', '');

update wp_posts set guid = replace(guid, '', '');

update wp_options set option_value = replace(option_value, '', '');

update wp_postmeta set meta_value = replace(meta_value, '', '');


Francisco Javier Carazo Gil answers:

You can try a high level redirect. Without using .htaccess to avoid problems trying to make difference between post and pages, in single.php you can do:

echo "<script>document.href.location = " . $new_url . $post->post_name . "</script>"

Maybe it's not the best way to have a good SEO, but it is a way to solve your problem.