Htaccess 301 redirect page to another?

Htaccess 301 redirect page to another?

Write this code into your .htaccess file:

Redirect 301 / http://new-website.com/

You won’t have to make 301 redirect php scripts for all the other pages. To test it, try loading an internal page like oldwebsite.com/page1.html. With the 301 redirect code from htaccess, you should be instantly redirected to your new website, new-website.com/page1.html.

Be sure also to declare the moving of the domains from webmaster tools. From Webmaster Tools, click on your old website > click on the “options wheel” > address change.


Another thing. If you don’t want that the users from a certain country to access your website, check this page and write the generated code into .htaccess. Make sure to put the redirection code after the banning code.
This way, nobody from certain countries will know that you are moving your website to a new domain.

If you have questions, leave in the comments.

Add a comment: