How to set up a 301 Permanent Redirect using .htaccess

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:


Repeat for every page you wish to redirect.

Code to redirect to a new domain

Place the following line into your .htaccess file:

RedirectPermanent /

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:

    1. Go to your HostPapa cPanel.
    2. In the Files section of the cPanel, click File Manager.Create a .htaccess File Using File Manager
    3. The File Manager opens in a new tab. Click the Settings button at the top right.Create a .htaccess File Using File Manager
    4. In the Preferences window, check the Show Hidden Files checkbox. Click the Save button.Create a .htaccess File Using File Manager
    5. The File Manager window now shows all files, including hidden ones. In the Files panel, double-click the public_html item.Create a .htaccess File Using File Manager
    6. 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.
    7. Click the +File button at the top left.Create a .htaccess File Using File Manager
    8. In the New File window, enter the filename as .htaccess and click Create New File.Create a .htaccess File Using File Manager
    9. The .htaccess file appears in the list.Create a .htaccess File Using File Manager
    10. Click once on the .htaccess file to select it, then click Edit.Create a .htaccess File Using File Manager
    11. In the Text Editor dialogue box, scroll down and make sure utf-8 is selected. Then click the Edit button.Create a .htaccess File Using File Manager
    12. 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.
    13. When you’re done editing the .htaccess file, click the Save Changes button at the top right of the Text Editor window.
    14. You can now close the Text Editor tab.

    How to implement a .htaccess file using FTP

    To implement a .htaccess file using FTP:

    1. 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.
    2. Use your FTP client to access your site. Make sure to set your FTP client to view hidden files.
    3. Go to the public_html directory.
    4. Upload your new .htaccess file to the public_html directory.
    5. 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.

Was this article helpful?

  • Was this article helpful ?

  • yes   no

Related Articles

Leave A Comment?