How to set posts redirect to a new domain

How to set posts redirect to a new domain

Last Updated: June 28, 2017 | Reading Time: < 1 minute

I’m moving out a blog to a new domain, and redirect all posts specifically to a new domain.

http://olddomain.com/category/postname

should go to

http://newdomain.com/category/postname

Apache Server

On Apache that allows .htaccess, you can add this line on top of the file:

RewriteEngine on
RewriteRule ^(.*)$ http://www.newsite.COM/$1 [R=301,L]

Nginx Server

On Nginx, add this line on server block configuration file:

server {
return 301 http://newdomain.com$request_uri;
}

Reload or restart Nginx for the change to take effect.

 

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Any idea? Fill the comment below

    This site uses Akismet to reduce spam. Learn how your comment data is processed.