Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 11 of 11
  1. #1
    Member shaky's Avatar
    Join Date
    May 2003
    Posts
    53

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

    Hi,

    I'm looking for a way to be able to redirect a person who goes to http://www.domain.com/admin/index.htm to automatically be redirected to https://www.domain.com/admin/index.htm

    Is there a way I can write this in .htaccess?

    Many Thanks.

  2. #2
    Member shaky's Avatar
    Join Date
    May 2003
    Posts
    53

    Default

    Ok,

    I did it with a really crude hack, in .htaccess I simply put the following line in:

    Redirect permanent /admin/index.htm https://www.domain.com/admin/index_admin.htm

  3. #3
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    You can do this for all pages using the following in your .htacces file instead:

    Code:
    RewriteEngine on
    RewriteCond   %{SERVER_PORT}  !^443$
    RewriteRule   ^(.*)?$   https://%{SERVER_NAME}/$1 [L,R]
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  4. #4
    Member shaky's Avatar
    Join Date
    May 2003
    Posts
    53

    Default

    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

    Originally posted by chirpy
    You can do this for all pages using the following in your .htacces file instead:

    Code:
    RewriteEngine on
    RewriteCond   %{SERVER_PORT}  !^443$
    RewriteRule   ^(.*)?$   https://%{SERVER_NAME}/$1 [L,R]

  5. #5
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    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
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  6. #6
    Member shaky's Avatar
    Join Date
    May 2003
    Posts
    53

    Default

    I have an index.php, but that should not make any difference...should it?

    Thx.

  7. #7
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    If you browse to:

    http://www.yourdomain.com/admin/index.php

    Does it switch to https and work?
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  8. #8
    Member shaky's Avatar
    Join Date
    May 2003
    Posts
    53

    Default

    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. #9
    Super Moderator This forum account has been confirmed by cPanel staff to represent a vendor. chirpy's Avatar
    Join Date
    Jun 2002
    Location
    Go on, have a guess
    Posts
    13,495

    Default

    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
    Jonathan Michaelson

    Need your cPanel servers secured and tuned?
    cPanel Server Configuration, Security, Recovery and Antivirus/AntiSpam Services
    Developers of the most effective (and free) Firewall & Security Solution for cPanel Servers - csf
    http://www.configserver.com

  10. #10
    Member shaky's Avatar
    Join Date
    May 2003
    Posts
    53

    Default

    Well thanks for your time, I will keep your code in mind if I need a total domain redirect in the future

  11. #11
    Member isputra's Avatar
    Join Date
    May 2003
    Location
    Mbelitar
    Posts
    593

    Default

    I use this :

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

    And any redirect to subdomain without problem
    It's me ...... It's me ......

Similar Threads & Tags
Similar threads

  1. Always redirect to SSL malfunction...
    By Netcrusher in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 03-12-2011, 05:10 AM
  2. SSL Redirect
    By aeboi80 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 09-29-2010, 12:36 PM
  3. SSL Redirect
    By grayloon in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 06-29-2010, 01:03 AM
  4. SSL redirect question
    By michaelbhahn in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 01-08-2008, 01:26 PM
  5. SSL redirect popup
    By Secret Agent in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 01-06-2006, 11:47 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube