I have moved my wordpress blog to new domain.

Old Address : domainname.com/blog | New Address : newdomainname.com

Please pay attention about old address and new address.

Now I want to redirect all old pages to new blog ( should be 30 redirection).

I could not find way to do it properly because I moved my blog to new domain from old domain directory.



WAY #1 - cPanel

I assume your host is using cPanel managing your Server.

Browse domainname.com/cpanel, login their with cPanel credential:
enter image description here

Change the values according the following image:
enter image description here

Don't forget to check the "Wildcard Redirect" to redirect all the subfolder/subpages also (Thanks to @RobertHue). Add the redirection and you are done.

WAY #2 - .htaccess

Open up your .htaccess of domainname.com/blog/ in edit mode. Put the following code there (I made it using WebConfs.com Redirect Generator):

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://newdomainname.com/$1 [R=301,L]

Save it. And yala!


That's well said by @RobertHue. I did not mention the subfolder or subpages redirection. So I edited my answer, changed the attached images and posted new code. Thanks a lot @RobertHue for pointing the important things.

  • Thanks you so much for your answer :-) I will try this one. :-)
    – Sasa1234
    Nov 25 '14 at 6:45
  • 1
    You didn't consider redirecting pages/posts in your solution.
    – Robert hue
    Nov 25 '14 at 6:47
  • Roberthue: Thanks a lot. I fixed my Answer now. @Sasa1234 please check the new answer and follow accordingly. Nov 25 '14 at 7:33
  • I tried way 1. Even I select Wildcard Redirect, redirecting works for only home page :-(
    – Sasa1234
    Nov 25 '14 at 8:35

Below query will help you to replace old pages to new domain :

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';

Here is a simple redirect, where we are trying to send a user visiting an old post to a new post.

Redirect 301 /a-very-old-post/ /a-very-new-post/

You can add the code above preferably at the start of your .htaccess file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.