Hi, I install my wordpress site on an ubuntu 18.04 droplet and after posting a few articles I proceed to install lestencrypt.
My https site works fine, my problem is when trying to enter with http it does not redirect.
This is the .httacces file from my site:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
And my 80 VirtualHost at /etc/apache2/sites-available (instead of example is my domain):
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/onemoreshot
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/onemoreshot/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
And my 443 VirtualHost at /etc/apache2/sites-available (instead of example is my domain)
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
I tried both, redirection by .httaccess and by VirtualHost. I’m using google domain.
Thanks in advance
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Hi there @juanmorschrott,
As you’re using WordPress for your website, it may be much easier to use a WordPress plugin to handle the HTTP->HTTPS rewrites instead of setting up yourself with rewrite rules.
I would suggest a plugin such as https://wordpress.org/plugins/really-simple-ssl/#installation to achieve this. You should be able to install it from your WordPress panel under the plugins menu.
Before installing it, I suggest removing your attempts to do the redirection from your htaccess & virtualhost files to avoid any possible issues caused by rule collisions etc.
Hope that helps! - Matt.
I’ve been looking through the provided annotations and I can’t seem to find one that toggles the ‘Http to Https’ redirect option on DO load balancers?
( I went through this file: https://github.com/digitalocean/digitalocean-cloud-controller-manager/blob/master/do/loadbalancers.go )
At the moment my setup is like this ( terraform based ) :
What would be the expected annotations for this ( if it is available)? Or what would be an alternative? For now, I’m making the adjustment manually once the load balancer has been provisioned, but that’s really not the expected way of working for me :/
Loving from Rohit Manglik.