Results 1 to 7 of 7
  1. Talking Redirect .htaccess Question -- Please Advise

    Hello WHT'ers,

    Okay, here is the scenario--

    I am trying to create a redirect with .htaccess so that if anyone goes to the following addresses (listed below) it will redirect them to https://www.domain.com

    http://www.domain.com
    http://domain.com
    https://domain.com

    Right now, using the code below, the redirect works with http://www.domain.com AND http://domain.com but NOT with https://domain.com.

    So, what do I need to add/change in the .htaccess file so that https://domain.com redirects to https://www.domain.com

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

    Thank you in advance for any help!
    Warmest regards,
    Chris
    ZiggyHost - Web Hosting Made Simple

  2. #2
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,849
    You mean https://domain.com redirects to http://www.domain.com? If so use
    RewriteCond %{SERVER_PORT} ^80$
    to limit a rule to http and / or
    RewriteCond %{SERVER_PORT} ^443$
    for https
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  3. Hello foobic,

    I mean https://domain.com redirects to https://www.domain.com.

    Thank you for your help!
    Warmest regards,
    Chris
    ZiggyHost - Web Hosting Made Simple

  4. #4
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,849
    Sorry, didn't make myself very clear there... What I meant was:

    When you say it doesn't work, do you mean that https://domain.com is now redirecting to http://www.domain.com? If so etc etc.

    In short, use the server port to determine whether you're on an ssl connection and redirect accordingly.
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  5. I should have been more clear as well. The whole point of trying to get https://domain.com to redirect to https://www.domain.com is so that I don't get a "Security Error: Domain Name Mismatch" error since the certificate is for www.domain.com NOT domain.com. I hope that makes sense.
    Warmest regards,
    Chris
    ZiggyHost - Web Hosting Made Simple

  6. #6
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,849
    In terms of the redirects, something like this should do what you want:
    Code:
    RewriteCond %{HTTP_HOST} ^domain\.com$
    RewriteCond %{SERVER_PORT} ^443$
    RewriteRule (.*) https://www.domain.com/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^domain\.com$
    RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
    BUT if you go to https://domain.com you'll get the security warning before you even get to the redirect - you can't stop that. Normally it's not an issue because the links to your checkout should be all under your control anyway, so you can make sure they all use https://www.domain.com.

    HTH
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  7. Hello foobic,

    Thank you for all your help! I really appreciate it!
    Warmest regards,
    Chris
    ZiggyHost - Web Hosting Made Simple

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •