Configure redirects in cPanel


What is a redirect?

A redirect is a way to automatically send visitors from one URL to another. It's useful for:

  • Redirecting from HTTP to HTTPS
  • Redirecting from domain without www to with www (or vice versa)
  • Redirecting old pages to new ones
  • Redirecting old domains to new ones
  • Maintaining SEO when changing URLs

Types of redirects

  • 301 (Permanent): Indicates the URL moved permanently. Search engines update their indexes.
  • 302 (Temporary): Indicates the redirect is temporary. Search engines keep the original URL.

Recommendation: Use 301 for most cases, especially when permanently changing URLs.


Method 1: Using cPanel Redirects tool

1. Access cPanel

  • Go to your cPanel panel
  • Log in with your credentials

2. Go to Redirects section

On the cPanel main page, look for the "Domains" section and click on "Redirects".

You can also search for it using the search box at the top of cPanel.


3. Create a redirect

In the "Create a Redirect" section:

  • Type: Select "Permanent (301)" or "Temporary (302)"
  • https?://(www\.)? Leave this as is or modify as needed
  • Domain: Select the domain
  • Redirect to: Enter the complete destination URL (e.g., https://yourdomain.com/new-page)
  • Redirect to www: Check if you want to redirect to www version
  • Redirect from www: Check if you want to redirect from www to non-www

Click "Add".


Common redirect examples

Redirect HTTP to HTTPS:

  • Type: Permanent (301)
  • Domain: yourdomain.com
  • Redirect to: https://yourdomain.com$1

Redirect non-www to www:

  • Type: Permanent (301)
  • Domain: yourdomain.com
  • Redirect to: https://www.yourdomain.com$1
  • Redirect from www: Unchecked

Redirect www to non-www:

  • Type: Permanent (301)
  • Domain: yourdomain.com
  • Redirect to: https://yourdomain.com$1
  • Redirect from www: Checked

Redirect specific page:

  • Type: Permanent (301)
  • Domain: yourdomain.com
  • Redirect to: https://yourdomain.com/old-pagehttps://yourdomain.com/new-page

Method 2: Using .htaccess

For more advanced redirects, you can use .htaccess:

  1. In cPanel, open "File Manager"
  2. Navigate to public_html
  3. Edit or create the .htaccess file
  4. Add redirect rules

Example: Redirect HTTP to HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Example: Redirect non-www to www

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Example: Redirect specific page

Redirect 301 /old-page /new-page

Example: Redirect entire domain

RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain\.com$ [NC]
RewriteRule ^(.*)$ https://new-domain.com/$1 [L,R=301]

Manage existing redirects

To see, edit or delete redirects:

  1. In the "Redirects" section, you'll see a list of active redirects
  2. You can edit or delete each redirect
  3. Click "Delete" to remove a redirect

Advanced redirects with .htaccess

Redirect multiple pages:

Redirect 301 /page1 /new-page1
Redirect 301 /page2 /new-page2
Redirect 301 /page3 /new-page3

Redirect with conditions:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/old-category/
RewriteRule ^old-category/(.*)$ /new-category/$1 [L,R=301]

Redirect everything except certain files:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/keep-this-page
RewriteRule ^(.*)$ https://new-domain.com/$1 [L,R=301]

Verify redirects

To verify a redirect works:

  • Access the original URL in your browser
  • Verify it redirects to the destination URL
  • Verify the status code is 301 or 302 (you can use browser developer tools)
  • Use online tools like httpstatus.io to verify status code

Common problems

Redirect doesn't work

  • Verify syntax is correct
  • Verify .htaccess file is in the correct directory
  • Verify mod_rewrite is enabled
  • Clear browser cache
  • Verify there are no conflicts with other rules

Infinite redirect loop

  • Verify destination URL doesn't redirect back to original
  • Review rule conditions
  • Verify there are no multiple conflicting redirects

Redirect works but loses parameters

  • Make sure to include $1 or $2 in the rule to preserve parameters
  • Use [QSA] to preserve query strings

Best practices

  • Use 301 for permanent changes: Helps maintain SEO
  • Test before implementing: Test redirects in a development environment
  • Document redirects: Keep a record of what you redirected and why
  • Verify regularly: Check that redirects still work
  • Avoid long chains: Don't create chains of multiple redirects
  • Keep necessary redirects: Don't delete old redirects too soon

Tips

  • Use cPanel tool when possible: It's easier and less error-prone
  • Use .htaccess for complex cases: For more advanced redirects
  • Verify after creating: Always verify the redirect works
  • Monitor SEO: Check that redirects don't negatively affect SEO
  • Update internal links: Update internal links to new URLs

Need help?

If you're having trouble configuring redirects in cPanel, open a ticket from the billing.baires.host panel or contact us for support.

You can also reach us through our social media:

Was this answer helpful? 0 Users Found This Useful (0 Votes)