Awais Imran
Awais Imran

Reputation: 1344

Wordpress blog URL redirect

Two questions only:

  1. I have a website including a section of Blog in wordpress. Now requirements are changed and my client wants me to make a blog section on a different domain. He wants the website and the blog on different domains. Yesterday I setup the blog on a different server but the problem is when I click on any post it takes to me to the post on the old domain. Any idea how can I fix that issue?

  2. Also we have sent out so many newsletters to our customers in which we have posted URLs of the old domain. Is it possible to redirect them to the post on the new domain and what is the process?

I really appreciate if you give me articles or tutorial links that can help me in this as I am not a PHP guy.

Upvotes: 0

Views: 215

Answers (1)

Sachin Khosla
Sachin Khosla

Reputation: 1716

That's an interesting stuff, so here's how you should proceed -

Solution to your first question is to replace the old domain with new one in the MySQL dump file. Before you proceed, please take the backup of your database, just in case you mess around. But this solution works the best, since I transfer client's websites from my Devserver to the live servers ever now & then. Follow these steps -

  1. Open your new hosting's cpanel or dump mysql file using the mysqldump command from shell
  2. Open this dump file in your favorite text editor and simply do find "http://old_domain.com" and replace with "http://new_domain.com" , it will replace the all the meta entries,post entries etc. Now save htis file.
  3. Truncate the database tables of the new domain's database (do not worry, we have the backup)
  4. Import the SQL file which you saved in step 2, and you are done!

Solution to your Second Question is to setup .htaccess redirect. I am sure you are using apache server, cause everyone does that :) , it's pretty easy to setup .htaccess redirect using which you can redirect all the visitors visiting old website to the new website URL. I used the following code on my blog few years back, and have a blogpost on how to setup apache redirect to new domain, just in case you want to know more about it.

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

Do let me know if something is unclear, I will try to clarify it.

Cheers,

Sachin Khosla

Upvotes: 1

Related Questions