The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Redirect HTTP with www to HTTPS without www

Discussion in 'Bind / DNS / Nameserver Issues' 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:

    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

    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:
    86
    Likes Received:
    2
    Trophy Points:
    8
    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:
    0
    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

    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 :

    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 :

    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. 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