Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Mar 2004
    Posts
    710

    Default Http to Https Redirection

    I am trying to have a http redirection to https. Everything I see, seems to be real simple, but does not work both ways.


    Domain = mydomain.com
    Directory = payme
    File = index.php


    So, I have an .htaccess file in the directory payme that states:

    Code:
    <IfModule mod_ssl.c>
    SSLRequireSSL
    </IfModule>
    <IfModule !mod_ssl.c>
    # no non-ssl access
    Redirect permanent / https://www.mydomain.com/
    </IfModule>
    Everything I read says that should work, but not.

    I also tried:

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond &#37;{HTTP_HOST} ^www\.mydomain\.com
    RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301]
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^index\.php$ https://mydomain.com/payme/ [R=301,L]
    Last edited by lloyd_tennison; 06-26-2007 at 04:36 PM.
    Lloyd F Tennison

  2. #2
    Member
    Join Date
    Mar 2004
    Posts
    710

    Default

    It seems even with only this in .htaccess

    Code:
    <IfModule !mod_ssl.c>
    # no non-ssl access
    Redirect  permanent / http://www.google.com
    </IfModule>
    Nothing happens. Opens index.php in that directory and does not send to google.
    Lloyd F Tennison

  3. #3
    Member
    Join Date
    Jun 2007
    Posts
    36

    Default

    Try the following code, it is working nicely on my site.

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    RewriteRule www(.*) https://yourHTTPSdomain.com%{REQUEST_URI}
    Expedio Servers Clustered Dedicated Servers

    Failsafe Clusters | Fully Redundant | Supports all leading control panels
    Get 99.999% uptime even if hardware fails!

  4. #4
    Member
    Join Date
    Dec 2004
    Posts
    42

    Default

    Quote Originally Posted by expedio View Post
    Try the following code, it is working nicely on my site.

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    RewriteRule www(.*) https://yourHTTPSdomain.com%{REQUEST_URI}

    I gave it a try and for the most part it works but there is one issue.

    The cert is for www.domain.com. So when someone goes to http://www.domain.com it redirects them to https://www.domain.com no problem.

    However when someone goes to http://domain.com it redirects them to https://domain.com, since the server is made for www.domain.com that gives them a warning in the browser that the cert does not match the URL.

    Does anyone have any ideas on what modrewrite command may work to solve that dilemma.

    Thanks in advance.

Similar Threads & Tags
Similar threads

  1. Wildcard SSL and https redirection
    By KaKtusSs in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-01-2010, 09:57 AM
  2. https redirection
    By TheNetway in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 11-14-2004, 12:04 AM
  3. Disallow https redirection BROKEN
    By danielaugustus in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 02-04-2004, 02:19 PM
  4. Redirection re: HTTP / HTTPS
    By Global Designz in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 09-18-2003, 01:08 PM
  5. www.website.com/cpanel redirection to https:// instead of http://
    By I-Web in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 07-15-2003, 09:59 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube