Simple 301 htaccess redirect to other domain or page

, , , , , , , ,

I found too much information about this and all I needed was this simple code that needs to be placed in .htaccess file. This invisible file is located in server in the root of your site. This code will redirect old page to new domain page.

You need FTP access to your server files to locate .htaccess file.

Here is your code:

RewriteEngine On
RedirectMatch 301 ^/old_site_url/ https://newdomain.com/new_site_url/
RedirectMatch 301 ^/old_site_url_2/ https://newdomain.com/new_site_url_2/
RedirectMatch 301 ^/old_site_url_3/ https://newdomain.com/new_site_url_3/

You need to redirect every page url separately. This gives you freedom to redirect different static pages to different domains if you wish.

Polylang plugin for WordPress

If you are working on WordPress and you use Polylang plugin, you need to redirect from home page too. Here is code for that. Just replace your country code to this snippet (ru/fi/en/).

RedirectMatch 301 ^/ru/ https://newdomain.com/
RedirectMatch 301 ^/fi/ https://newdomain.com/
RedirectMatch 301 ^/en/ https://newdomain.com/