[SOLVED] Redirect Error: Wordpress + Let's Encrypt (Certbot) + SSL only + non-www

SOLVED: http://stackoverflow.com/questions/39948113/redirect-error-wordpress-lets-encrypt-certbot-ssl-only-non-www


I badly configured my apache conf-files and now I’m getting a redirect error (ERR_TOO_MANY_REDIRECTS). I want to redirect everything to HTTPS (non-www). I already tried to add this to the wp-config.php regarding this tips, but that didn’t solve the problem:

define('WP_HOME','http://d0main.xyz');
define('WP_SITEURL','http://d0main.xyz');

and I tried to add

define('WP_HOME','https://d0main.xyz');
define('WP_SITEURL','https://d0main.xyz');

Here are my Apache files:

d0main.xyz.conf

<VirtualHost *:80>

ServerName d0main.xyz
ServerAlias www.d0main.xyz
ServerAdmin contact@d0main.xyz
DocumentRoot /var/www/html
Redirect permanent / https://d0main.xyz

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

d0main.xyz-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>

ServerName d0main.xyz
ServerAlias www.d0main.xyz
ServerAdmin d0main@d0main.xyz
DocumentRoot /var/www/html
Redirect permanent / https://d0main.xyz

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
# changed from None to FileInfo
AllowOverride FileInfo
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
SSLCertificateFile /etc/letsencrypt/live/d0main.xyz/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/d0main.xyz/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
</VirtualHost>

</IfModule>
<IfModule mod_rewrite.c>

For the solution see this post: http://stackoverflow.com/questions/39948113/redirect-error-wordpress-lets-encrypt-certbot-ssl-only-non-www

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.