0

I installed an apache webserver and created a website. Let's Encrypt is used for https. I followed the auto-configuration process and the non-www url works fine. But if I want to redirect https://www to https://xxxxx.com with a .htaccess it doesn't work.

I tried with the following settings:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^.*$ https://%1/$1 [R=301,L]

mod_rewrite is enabled.

  • What is the error you get ? Do you have any rewrite logs ? – Froggiz Dec 7 '15 at 10:33
1

First of all, is the certificate even valid for the www-Host? If not, get a second one for the www-host and put that a separate <VirtualHost *:443>.

If the certificate is valid for the domain and the www-host, it sounds to me as if there is a ServerAlias for the www-Host missing in the <VirtualHost *:443>

Also, you'll have to put the "dot asterisk" in round brackets for the $1 to work (like you did in the RewriteCond for %1):

RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*) RewriteRule ^(.*)$ https://%1$1 [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy