A 301 Permanent Redirect permanently redirects one URL to another. Use a 301 redirect to send visitors to a new URL, and to tell search engines that a page has moved so the new page will be properly indexed.
Common uses of a 301 redirect:
- After a move to a new domain, use a 301 redirect on the old domain to send visitors to the new site.
- After moving old site pages to a new site structure, use 301 redirects to send users to the new pages.
- After combining two sites, use 301 redirects to ensure visitors go to the new pages.
On HostPapa sites, use .htaccess files to create and manage redirects. You can create a .htaccess file by using the File Manager in cPanel, or by using FTP to upload a .htaccess file you create with a text editor on your computer.
Note: A .htaccess file is a hidden file, so you’ll need to configure the cPanel File Manager or FTP client to see hidden files on your system. See the instructions below.
Developer tip: If the site doesn’t work after updating or adding the .htaccess file, restore site functionality by either renaming or removing the file.
Code to redirect to a page
Place the following line into your .htaccess file:
RedirectPermanent http://www.domain.com/old-file.html http://www.domain.com/new-file.html
Repeat for every page you wish to redirect.
Code to redirect to a new domain
Place the following line into your .htaccess file:
RedirectPermanent / http://www.new-domain.com/
How to implement a .htaccess file using the cPanel File Manager
The cPanel File Manager provides an easy way to create or access a .htaccess file. Here’s how:
-
- Go to your HostPapa cPanel.
- In the Files section of the cPanel, click File Manager.
- The File Manager opens in a new tab. Click the Settings button at the top right.
- In the Preferences window, check the Show Hidden Files checkbox. Click the Save button.
- The File Manager window now shows all files, including hidden ones. In the Files panel, double-click the public_html item.
- The contents of the public_html folder now display. This is where your .htaccess file will live. For a new site, there isn’t a .htaccess file yet, so you’ll need to create it.
- Click the +File button at the top left.
- In the New File window, enter the filename as .htaccess and click Create New File.
- The .htaccess file appears in the list.
- Click once on the .htaccess file to select it, then click Edit.
- In the Text Editor dialogue box, scroll down and make sure utf-8 is selected. Then click the Edit button.
- The text editor opens in a new tab. The window will be blank since it’s a new file. Enter the page or domain name redirect code as described above.
- When you’re done editing the .htaccess file, click the Save Changes button at the top right of the Text Editor window.
- You can now close the Text Editor tab.
How to implement a .htaccess file using FTP
To implement a .htaccess file using FTP:
- Create the .htaccess file on your computer using a text editor. Add the page or domain redirect code as described at the beginning of this article.
- Use your FTP client to access your site. Make sure to set your FTP client to view hidden files.
- Go to the public_html directory.
- Upload your new .htaccess file to the public_html directory.
- When the upload is complete, exit your FTP client.
If you need help creating a .htaccess file for your site, contact HostPapa Support for assistance.
Leave A Comment?