SYSTEM INFORMATION
OS type and version
Ubuntu 22.04
Webmin version
2.202
Virtualmin version
7.20.2
Webserver version
Apache2
Related packages
SUGGESTED
Hello
The Apache2 redirection from www.sitename.be to sitename.be don’t work.
If I try
http://www.sitename.be/contact Virtualmin must redirect both the HTTP to HTTPS and the WWW to “non-WWW” site.
but
http://www.sitename.be/contact → https://sitename.be/www.sitename.be/contact
Seem that error is in this line in the Apache2 VirtualHost port 80
RewriteCond %{HTTPS} off
RewriteRule ^/(?!.well-known)(.*)$ https://%{HTTP_HOST}/$1 [R]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} =www.sitename.be
RewriteRule ^/(?!.well-known)(.*)$ https://%{HTTP_HOST}/$1 [R]
It works for me…
But I’m NOT a specialist of the RewriteRule.
Thanks.
Didier Misson
Steini
November 25, 2024, 3:55am
2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
</IfModule>
1 Like
Same problem here…but on the contrary.
By establishing a new virtual server, I decided to simultaneously activate the redirection for the entire site through SSL protocol and simultaneously force all pages from non-WWW to WWW.
Among the various tests performed to verify the redirects, the one from the browser address line where I intentionally insert in combination both non-SSL and non-WWW URL i.e. http://myfantasyvirtualserver.com instead of giving back https://www.myfantasyvirtualserver.com the server redirects to https://www.myfantasyvirtualserver.com//myfantasyvirtualserver.com/
That scenario does not occur if I try with https://myfantasyvirtualserver.com
Just want to know if i need to do any more settings to fix the anomaly or is there a bug somewhere. Do I really have to edit Apache2 VirtualHost port 80 even if it seems to depend from something related to the settings under Web Configuration\Website Options?
Thank you in advance for your kind feedback.