How To Redirect Only Your Homepage

A client recently asked me how to redirect your homepage only and not any archive pages.

It took me a long while to figure it out, so for anyone else who’s searching for it, this is how it’s done. You need to add a line to the start of your website’s .htaccess file.

A 301 redirect won’t work as it will redirect the whole site, so you have to use a RedirectMatch. The code below will redirect the home page only to google.com, but leave any other pages and archives in place for people to come to your site.

RedirectMatch ^/$ http://google.com

There are a couple of reasons you might want to do this, so hope it helps!