How to Configure Redirects Manually

Last modified: 2026 January 27


Overview

A redirect automatically sends users from one URL to another.

While you can usually use cPanel’s Redirects interface (cPanel » Home » Domains » Redirects) to create your redirect, some third-party applications may require you to configure your .htaccess file manually.

When to set up manual redirects

When you create a redirect with the cPanel Redirects interface (cPanel » Home » Domains » Redirects), the system adds the redirect rules to the bottom of the .htaccess file. This behavior allows most redirect configurations to work as expected.

However, you may need to configure redirects manually in the following scenarios:

  • A third-party application considers only the rules within its own section of the .htaccess file, ignoring rules at the end of the file.
  • A content management system, such as WordPress®, adds rules that override or conflict with redirects created in cPanel.
  • Redirects do not work as expected due to rule order or specific requirements from a third-party application.

How to edit your .htaccess file

To edit your .htaccess file, perform the following steps:

  1. Navigate to cPanel’s File Manager interface (cPanel » Home » Files » File Manager).
  2. In the top navigation bar, click Settings. The Preferences interface will open.
  3. Select Show Hidden Files (dotfiles).
  4. Click Save. The Preferences interface will close.

Your .htaccess file will now appear in the public_html folder.

To learn more about the actions you can perform in cPanel’s File Manager interface (cPanel » Home » Files » File Manager), including editing your files, read our File Manager documentation.

Examples

Use the following examples to configure your redirects manually in your .htaccess file.

301 Permanent redirects

The following is a permanent redirect of an entire site from its original location to example.com:

Redirect 301 / http://example.com/

The following is a permanent redirect of a page on example.com to a different page on example.com:

Redirect 301 /original.html http://www.example.com/new.html

The following is a permanent redirect of an entire directory on example.com to a different directory on example.com:

Redirect 301 /old-directory http://www.example.com/new-directory

302 Temporary redirects

The following is a temporary redirect of an entire site from its original location to example.com:

Redirect 302 / http://example.com/

The following is a temporary redirect of a page on example.com to a different page on example.com:

Redirect 302 /original.html http://www.example.com/new.html

The following is a temporary redirect of an entire directory on example.com to a different directory on example.com:

Redirect 302 /old-directory http://www.example.com/new-directory

Drupal Redirect

The following example displays the configuration that you must add to the top of the .htaccess file to add a redirect for the Drupal content management system. In this example:

  • drupal.user.example.com represents the URL to redirect.
  • http://cpanel.net/ represents the URL to which to redirect.
1
2
3
4
5
6
7
8
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} ^drupal\.user\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.drupal\.user\.example\.com$
RewriteRule ^cptest$ "http\:\/\/cpanel\.net\/" [R=301,L]
</IfModule>

Additional Documentation