I recently decided that since I didn’t currently have much on my home page (which resides at the root level of my site), it would be better to redirect users to the Console page until I had more to put on my home page. Here’s a mini-tutorial on how to redirect visitors from the root of your site to another page of your choice.
There’s only one step! Insert the following rule into your .htaccess Apache file:
# This will only redirect a request that begins and ends with a slash (i.e. a request to the root) RedirectMatch ^/$ [Path or URL to redirect users to]
Obviously you replace [Path or URL to redirect users to] with the actual path/URL to which you want to redirect users. For example, to redirect users to the Console section on my site, I’d write either:
# Using a URL RedirectMatch ^/$ http://quintusquill.com/console/
…or:
# Using a Path RedirectMatch ^/$ /console/
The reason why we use the RedirectMatch command instead of the regular Redirect command is that if we write, for example:
Redirect / http://quintusquill.com/console/
…it redirects all requests to http://quintusquill.com/console/—not just those going to the root. So if the user requests, say, http://quintusquill.com/about/, they will be redirected to http://quintusquill.com/console/about/ (not what we want!).
Thankfully, using the RedirectMatch command, we are able (by using a regular expression) to only redirect requests to the site root.
