Skip to content
Atlas Hoster
Website › Redirections et erreurs

Redirect a page or force HTTPS: 301 redirects and .htaccess

Updated on 18 November 2026Checked on cPanel 138 on 11 November 2026

A 301 redirect permanently sends visitors (and search engines) from one address to another. In cPanel you create one in a few clicks, and the .htaccess file lets you go further, for example to force HTTPS.

Before you start

  • You can access cPanel (see the article "Log in to cPanel").
  • To force HTTPS, a valid certificate must already be installed on the domain (see "Install an SSL certificate in cPanel"). Otherwise visitors will see a security warning.
  • Before editing .htaccess, make a copy of the file: a syntax error shows an error page on the whole site.

Steps: create a 301 redirect in cPanel

  1. Open the redirects screen. In cPanel, under "Domains", click Redirects (shown as Redirects in French).
  2. Choose the type. In the Type menu, pick Permanent (301): the address has changed for good and search engines update their index. Temporary (302) is for a temporary move, for example during maintenance.
  3. Choose the domain, or All Public Domains for every domain on the account.
  4. Enter the original page. In the box after the domain name (the "/" field), type the rest of the address to redirect. To redirect your-domain.com/old-page.html, type old-page.html. Leave it empty to redirect the whole domain.
  5. Enter the destination in Redirects to, with the protocol: https://your-domain.com/new-page.html. The protocol (http://, https://) is required.
  6. Set "www.": Only redirect with www., Redirect with or without www. or Do Not Redirect www.. This setting is disabled if you chose All Public Domains.
  7. If needed, tick "Wild Card Redirect" to redirect every file in a folder to the same file name in the new folder (old.com/photo.jpg to new.com/photo.jpg).
  8. Click "Add". To test it, click the link in the Directory column of the Current Redirects table.
<!-- ILLUSTRATION À VENIR (plan A.7) : capture annotée de l'écran Redirections de cPanel. Rien de créé ici. -->

An existing redirect cannot be edited: delete it (Delete in the Current Redirects table) then create it again.

Force HTTPS

Simple method. According to the cPanel documentation, to send visitors from the insecure version of a domain to the secure one, use the Force HTTPS Redirect option of the Domains screen (the "Domains" section of cPanel), not the Redirects screen.

Manual method, with .htaccess. Useful if your application (WordPress, for example) ignores the rules cPanel adds. When you create a redirect in cPanel, the system adds it at the bottom of .htaccess, and some applications only read their own section.

  1. Open the File Manager, click Settings (at the top), tick Show Hidden Files (dotfiles), then Save. The .htaccess file appears in public_html.
  2. Make a copy of .htaccess, then edit the original.
  3. Add these lines at the very top of the file:
RewriteEngine On
RewriteCond "%{HTTPS}" !=on
RewriteRule "^(.*)$" "https://%{HTTP_HOST}/$1" [R=301,L]

The Apache documentation describes this recipe (a condition "the connection is not HTTPS", then a permanent R=301 redirect) as the solution when you only have access to .htaccess.

  1. Save, then open http://your-domain.com: the address must become https://your-domain.com.

Remove (or add) "www"

To always show the address without www, add this to .htaccess, in the same place:

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

For the opposite (always with www), the Apache documentation uses the condition RewriteCond "%{HTTP_HOST}" "!^www\." [NC] followed by a rule that adds www. to the host name. Pick one form and keep it everywhere (links, sitemap, certificate).

Redirect a single page with .htaccess

The cPanel documentation gives these examples:

Redirect 301 /old-page.html https://your-domain.com/new-page.html
Redirect 301 /old-folder https://your-domain.com/new-folder

The second line also redirects everything under /old-folder.

Expected result

The old address opens the new one, and the browser's address bar shows the new one. For HTTPS, the address bar shows https:// with the padlock.

If something goes wrong

  • Error page on the whole site after an edit. A line in .htaccess is wrong. Put back the copy made in step 2, then start again adding lines one at a time.
  • "Too many redirects" (loop). Two rules contradict each other: for example forcing www in .htaccess and redirecting to non-www in cPanel. Keep a single rule per subject.
  • The redirect does nothing. Browsers keep redirects in memory: the cPanel documentation advises clearing the browser cache. Also test in a private window.
  • WordPress ignores the cPanel redirect. Put the rule at the very top of .htaccess, before the WordPress section.
  • No padlock after forcing HTTPS. The certificate is missing or does not cover this name; see "Install an SSL certificate in cPanel".

Frequently asked questions

What is the difference between a 301 and a 302 redirect? A 301 is permanent and asks search engines to update their records; a 302 is temporary and has no effect on those records, according to the cPanel documentation.

Where is the .htaccess file? In public_html (the site root), but it is hidden: enable "Show Hidden Files" in the File Manager settings.

Can a cPanel redirect and .htaccess rules be combined? Yes, cPanel itself writes its redirects into .htaccess. Just watch the order of the rules and avoid contradictions.

Can I redirect a whole domain to another one? Yes: choose the domain in the Redirects screen, leave the "/" field empty and enter the destination address with its protocol.

Going further

Need a hosting space with cPanel and a certificate for your site? Discover our web hosting.

WebsiteAll guides