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.

wildcart redirect? - http://www.mydomain.com -> http://mydomain.com

Discussion in 'General Discussion' started by SoftDux, Mar 29, 2007.

  1. SoftDux

    SoftDux Well-Known Member

    Joined:
    May 27, 2006
    Messages:
    983
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Johannesburg, South Africa
    cPanel Access Level:
    Root Administrator
    Hi all

    I want to redirect all request to a certain subdomain to http://sub.domain.com - due to the fact that there's a SSL on that domain

    So, if someone were to type in http://www.sub.domain.com, I need it to be rediredted to https://sub.domain.com, but can't see to figure out how.


    Here's the code I have so far:

    Code:
    # RewriteEngine on
    # RewriteCond %{HTTP_HOST} ^sub.domain.com$ [OR]
    # RewriteCond %{HTTP_HOST} ^www.sub.domain.com$
    # RewriteRule ^(.*)$ https://sub.domain.com [R=301,L]
    
    

    The problem is, if someone needs to access https://sub.domain.com/folder1/download/file.zip, but types in http://www.sub.domain.com/folder1/download/file.zip, he get's redirected to https://sub.domain.com

    What am I missing?

    tia :)
     
  2. critter

    critter Well-Known Member

    Joined:
    Nov 19, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Amarillo, Texas
    Anyone got an answer to this? I need to do the same thing.
     
  3. pross

    pross Well-Known Member

    Joined:
    Mar 14, 2005
    Messages:
    75
    Likes Received:
    0
    Trophy Points:
    6

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

    found that with google
     
  4. critter

    critter Well-Known Member

    Joined:
    Nov 19, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Amarillo, Texas
    Thanks Pross, I found this one in another thread.

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !443
    RewriteRule ^(.*)$ https://YOUR_DOMAIN/$1 [R,L]
     
  5. critter

    critter Well-Known Member

    Joined:
    Nov 19, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Amarillo, Texas
  6. critter

    critter Well-Known Member

    Joined:
    Nov 19, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Amarillo, Texas
    Would this work?

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://your_domain.com%{REQUEST_URI}
     
  7. critter

    critter Well-Known Member

    Joined:
    Nov 19, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Amarillo, Texas
    Well cool, I guess talking to yourself works wonders, the above works just great.

    Thanks Pross for pointing me in the right direction.
     
    #7 critter, Jun 7, 2007
    Last edited: Jun 7, 2007
Loading...

Share This Page