Rewrite domain on Linux hosting to redirect one domain to another

Linux HostingI transitioned from a Windows based host to a Linux based one last year when I changed web host. I had a reasonable understanding of redirecting one domain to another on the Windows host, but am now having to learn how to do it on Linux hosting.

I’ve tried doing it through the front-end cPanel controls, but find that it enver works. The most recent one I;’ve tried setting up, I spoke to the support team and they gave me the .htaccess settings for the redirect.

I am posting it here so that I can easily find it in future.

I was wanting a redirect from to to make short URLs available (or at least shorter URLs available). The below needs to be added to the .htaccess of the website on the domain you want to redirect:

#Redirect from old domain to new domain
RewriteEngine on
RewriteBase /
RewriteRule (.*)$1 [R=301,L]

Replace the highlighted domain with the one you want to redirect.