Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Redirect HTTP with www to HTTPS without www

Discussion in 'Bind/DNS/Nameserver' started by Faal, Jul 2, 2015.

  1. Faal

    Faal Member

    Joined:
    Jul 1, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    iran
    cPanel Access Level:
    Website Owner
    hi
    Please help me
    I need that my website is displayed only over SSL . Only
    and Remove www
    Only settings for file ".htaccess"

    for all addresses and sub-folders

    For example:
    Code:
    1: # Redirect HTTP without www to HTTPS without www
    http://domain.com/
    http://domain.com/wp-login.php
    
    2: # Redirect HTTP with www to HTTPS without www
    http://www.domain.com/
    http://www.domain.com/wp-login.php
    
    3: # Redirect HTTPS with www to HTTPS without www
    https://www.domain.com/
    https://www.domain.com/wp-login.php
    
    end result: Remove www and display website over https

    Code:
    https://domain.com/
    https://domain.com/wp-login.php
    
    Please give three answers :

    1: # Redirect HTTP without www to HTTPS without www

    2: # Redirect HTTP with www to HTTPS without www

    3: # Redirect HTTPS with www to HTTPS without www
     
    #1 Faal, Jul 2, 2015
    Last edited by a moderator: Jul 6, 2015
  2. lldeepakll

    lldeepakll Well-Known Member

    Joined:
    May 20, 2012
    Messages:
    85
    Likes Received:
    3
    Trophy Points:
    58
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hi,

    For your first two queries login to cPanel and click on Redirects option in Domains Section and

    * Select Type Permanent (301)
    * Select your domain (i.e. sample.com) (Leave the box empty after selecting domain from drop down)
    * redirectes to --> https://domain.com
    * Select "Redirect with or without www"

    That's It.

    Above settings will add following lines in .htaccess file.

    RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.domain\.com$
    RewriteRule ^/?$ "https\:\/\/domain\.com\/" [R=301,L]


    1: # Redirect HTTP without www to HTTPS without www

    RewriteCond %{HTTP_HOST} ^domain.com$
    RewriteRule ^/?$ "https\:\/\/domain\.com\/" [R=301,L]


    2: # Redirect HTTP with www to HTTPS without www


    RewriteCond %{HTTP_HOST} ^www\.domain\.com$
    RewriteRule ^/?$ "https\:\/\/domain\.com\/" [R=301,L]

    3: # Redirect HTTPS with www to HTTPS without www

    You mean https://www.domain.com ------> https://domain.com

    Unfortunately I don't know any htaccess rule for this redirection. IMO, you should set php redirection for this type of redirection. Or someone else can provide you solution for this.

    Thanks
     
    #2 lldeepakll, Jul 4, 2015
    Last edited by a moderator: Jul 6, 2015
  3. adewale

    adewale Registered

    Joined:
    Jul 5, 2015
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    nigeria
    cPanel Access Level:
    Website Owner
    thanks...
     
  4. Faal

    Faal Member

    Joined:
    Jul 1, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    iran
    cPanel Access Level:
    Website Owner
    Thanks
    But not all-encompassing perspective
    Code:
    http://domain.com/wp-login.php
    http://www.domain.com/wp-login.php
    https://domain.com/wp-login.php
    https://www.domain.com/wp-login.php
    
    So what is the answer?

    Please test, be sure to completely delete your browser's cache

    thanks
    but this Redirects for main pages is good :
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.(.*)
    RewriteRule ^.*$ https://%1/$1 [R=301,L]
    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    
    
    but for wordpress in each is good :

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
    
     
    #4 Faal, Jul 14, 2015
    Last edited by a moderator: Jul 14, 2015
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Faal

    Faal Member

    Joined:
    Jul 1, 2015
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    iran
    cPanel Access Level:
    Website Owner
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice