.htaccess redirect from old domain to new domain

Htaccess is a powerful tool. Simplest mistake in syntax can cause problems. In this post i am talking about the permanent redirect, ie 301 redirect of old domain to new domain.

Case 1: if you need to keep the url structure of old domain in the new one

eg: http://olddomain.com/hello gets redirected to http://newdomain.com/hello

Do this: if you plan to keep the url structure

+ve: Helps to retain the seo

Redirect 301 / http://newdomain.com/

Case 2: if you don’t need the url structure

eg: http://olddomain.com/hello gets redirected to http://newdomain

Do this: if you dont plan to keep the url structure

RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]

Enjoy smile


Comments

Let's discuss now…

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