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!

how can I redirect non-ssl sites to their ssl equivalent?

Discussion in 'General Discussion' started by shaky, Mar 29, 2004.

  1. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    156
  2. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    156
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    22
    Trophy Points:
    463
    Location:
    Go on, have a guess
    You can do this for all pages using the following in your .htacces file instead:

    Code:
    RewriteEngine on
    RewriteCond   %{SERVER_PORT}  !^443$
    RewriteRule   ^(.*)?$   [url]https://%[/url]{SERVER_NAME}/$1 [L,R]
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    156
    Thanks chirpy,

    I tried droping your code into my .htaccess file for domain.com/admin

    but just kept getting a 404 error.

    I must have done something wrong :(

     
  5. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    22
    Trophy Points:
    463
    Location:
    Go on, have a guess
    Odd. I just tested on a cPanel box and it worked fine. I even created a subdirectory called /admin and that worked too.

    Ah, I've just reread your original post. I guess you'll be getting a 404 because at domain.com/admin/ you don't have an index.htm but a index_admin.htm, according to your post, anyway ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    156
    I have an index.php, but that should not make any difference...should it?

    Thx.
     
  7. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    22
    Trophy Points:
    463
    Location:
    Go on, have a guess
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    156
    Unfortunately not;

    First I removed the redirect in .htaccess found in public_html folder, and then I copied your code exactly into the .htaccess file found in public_html/admin/ and I get a 404 error when going to http://www.domain.com/admin/index.php.

    Thx again, appreciate any advice.
     
  9. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,460
    Likes Received:
    22
    Trophy Points:
    463
    Location:
    Go on, have a guess
    Ahhhhhh,

    The code I mentioned was specifcally for the top level of the web root (i.e. in /public_html/.htaccess) it is intended for rerouting any requet on http:// to https:// for the whole domain.

    To redirect just the /admin, you're probably better of using your original redirect if it works for you ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    156
    Well thanks for your time, I will keep your code in mind if I need a total domain redirect in the future :p
     
  11. isputra

    isputra Well-Known Member

    Joined:
    May 3, 2003
    Messages:
    575
    Likes Received:
    0
    Trophy Points:
    166
    Location:
    Mbelitar
    I use this :

    <code>
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)?$ https://%{SERVER_NAME}%{REQUEST_URI}
    </code>

    And any redirect to subdomain without problem
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
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