How to redirect homepage via .htaccess
If you’d like to redirect your homepage to another URL, you need to use RedirectMatch. In case you use a regular 301 or 302 redirect instead, the whole site gets redirected.
Code to redirect the homepage
The following code can be added to the .htaccess file to redirect only the homepage. In case the redirect is temporary, for example when you launch a campaign and want to drive traffic to the campaign page, a 302 redirect would be the best choice. Keep in mind that if you keep a 302 redirect longer than a few weeks, Google will see it as permanent.
RedirectMatch 301 ^/$ https://example.com/example-page
RedirectMatch 302 ^/$ https://example.com/example-page
Why to redirect via the .htaccess file?
A permanent 301 redirect in your .htaccess file lets search engines and others know that an old link has been replaced by a new one. If your website is running on Apache, it’s the recommended method for directing traffic from an existing page.
Need any help?
If you need any help with setting up redirects via the .htaccess file, please feel free to reach out.