There are two types of redirects, a permanent and temporary redirect. We will be taking a look at temporary redirects. If you'd like to learn how to utilize a permanent redirect, please consult our guide, which covers this in detail: Set a permanent (301) redirect using .htaccess
How do I create a temporary redirect?
The first thing you'll need to do (if you haven't already) is creating a .htaccess file. If you're not certain how to create a .htaccess file, no worries, we have you covered with our guide: Creating and editing a .htaccess file. Once the .htaccess file has been created, you'll need to edit the contents of this file using the method that best suits your needs. Typically the options available to edit your .htaccess file are as follows.
- Use a file editor built into a file manager such as cPanel's file manager
- Download or create the .htaccess file locally and then re-upload it via FTP
- Edit the file directly using a text editor via SSH
Regardless of the method you're using, the code you'll be adding is the same. To redirect your entire website to a different URL, you'd use the following entry in the .htaccess file:
Redirect 302 / http://newwebsitehere.com/
The above will redirect your current website to a new site of your choosing. This is excellent if you're rebuilding your site and you'd like to direct visitors to a temporary site or landing page. To redirect a portion of your site, you'd place the following code in your .htaccess file:
Redirect 302 /old-page.html http://newsitehere/new-redirected-page.html
Once you're satisfied, save the file, and the redirect should be in place!