• Hey everyone, I recently have moved to HTTPS version from HTTP. But since then, I am into trouble and problem is not solved.
    So, my query is, How to redirect user to HTTPS version of site regardless whatever he types. For ex., Let me explain:-

    abc.com --->>> https://www.abc.com/
    www.abc.com --->>> https://www.abc.com/
    https://abc.com --->>> https://www.abc.com/

    Moreover, If in future I make my mind to move site to https://abc.com instead of https://www.abc.com, then what will be the code for this? Let me give example for this too.

    abc.com --->>> https://abc.com/
    www.abc.com --->>> https://abc.com/
    https://www.abc.com --->>> https://abc.com/

    >>> I have seen that if a user types https://abc.com and I want it to redirect to https://www.abc.com/ then browser give warning about its security before redirecting. Hence, asks for users confirmation. This is bad thing and can destroy site owner image. This should not happen. ??
    Please suggest .htaccess code for both types separately. For info, using Apache Web Server. ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    How are you hosting your site?

    Thread Starter xpsofficial

    (@xpsofficial)

    Digital Ocean Unmanaged VPS hosting. Doing everything manually with FileZilla.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    This is how I handle all the for an SSL site.

    In /etc/httpd/conf.d/mysite.conf I use CentOS. If you arr using Ubuntu/Debian, the file will be different.

    <VirtualHost *:80>
      ServerName mysite.org
      ServerAlias www.mysite.org
      DocumentRoot /var/www/mysite/wordpress
      CustomLog logs/mysite-access_log combined
      ErrorLog logs/mysite-error_log
      RewriteEngine On
      RewriteCond %{SERVER_PORT} 80
      RewriteRule ^(.*)$ https://mysite.org/$1 [R=301,L]
      RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
      RewriteRule ^(.*)$ https://%1$1 [R=301,L]
    </VirtualHost>
    
    <Virtualhost *:443>
       ServerName mysite.org
       ServerAlias www.mysite.org
       SSLEngine on
       SSLCertificateFile /etc/letsencrypt/live/mysite.org/cert.pem
       SSLCertificateKeyFile /etc/letsencrypt/live/mysite.org/privkey.pem
       SSLCertificateChainFile /etc/letsencrypt/live/mysite.org/chain.pem
       DocumentRoot /var/www/mysite/wordpress
       CustomLog logs/mysite-access_log combined
       ErrorLog logs/mysite-error_log
    </VirtualHost>
    Thread Starter xpsofficial

    (@xpsofficial)

    Actually I am using Ubuntu, I am looking for new configuration file. ?? intHow

    • This reply was modified 8 years, 2 months ago by xpsofficial. Reason: More Info
    • This reply was modified 8 years, 2 months ago by xpsofficial. Reason: Additional Info
    Thread Starter xpsofficial

    (@xpsofficial)

    I am currently facing same problem at https://crystalbreak.com/ and don’t really know how to redirect all non-https to naked https.

    Can anyone help here?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Redirect all HTTP requests to HTTPS’ is closed to new replies.