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!

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:
    994
    Likes Received:
    2
    Trophy Points:
    168
    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:
    156
    Location:
    Amarillo, Texas
    Anyone got an answer to this? I need to do the same thing.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. pross

    pross Well-Known Member

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

    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:
    156
    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]
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. critter

    critter Well-Known Member

    Joined:
    Nov 19, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    156
    Location:
    Amarillo, Texas
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. critter

    critter Well-Known Member

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

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://your_domain.com%{REQUEST_URI}
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. critter

    critter Well-Known Member

    Joined:
    Nov 19, 2003
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    156
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #7 critter, Jun 7, 2007
    Last edited: Jun 7, 2007
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