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.

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:
    53
    Likes Received:
    0
    Trophy Points:
    6
  2. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    53
    Likes Received:
    0
    Trophy Points:
    6
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    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]
    
     
  4. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    53
    Likes Received:
    0
    Trophy Points:
    6
    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,475
    Likes Received:
    20
    Trophy Points:
    38
    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 ;)
     
  6. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    53
    Likes Received:
    0
    Trophy Points:
    6
    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,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
  8. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    53
    Likes Received:
    0
    Trophy Points:
    6
    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,475
    Likes Received:
    20
    Trophy Points:
    38
    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 ;)
     
  10. shaky

    shaky Well-Known Member

    Joined:
    May 31, 2003
    Messages:
    53
    Likes Received:
    0
    Trophy Points:
    6
    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:
    576
    Likes Received:
    0
    Trophy Points:
    16
    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
     
Loading...

Share This Page