Some www domains not redirecting to https mixed case problem?

Ubuntu 18.04 LTS
Apache/2.4.29 (Ubuntu)
Rackspace - shell access

This has links and other questions

https://www.garyjohnsoninfo.info/SSLTests.html

The short story
Mixed case domain names in rewrite condition are not working
this does not redirect a www domain
RewriteCond %{SERVER_NAME} =DrKPeterHuberBlog.com [OR]
RewriteCond %{SERVER_NAME} =www.DrKPeterHuberBlog.com [OR]
RewriteCond %{SERVER_NAME} =drkpeterhuberblog.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

This does redirect a www domain
//all lowercase

RewriteEngine on
RewriteCond %{SERVER_NAME} =drcassidyboelkblog.com [OR]
RewriteCond %{SERVER_NAME} =www.drcassidyboelkblog.com [OR]
RewriteCond %{SERVER_NAME} =drcassidyboelkblog.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

I checked the
www.DrKPeterHuberBlog.com with http://www.redirect-checker.org/index.php It said its fine, but did not show the 301 permanent redirect that www.drcassidyboelkblog.com did. What can I do?

Why does this redirect correctly Redirects (no www in domain and lowercase )
http://drkpeterhuberblog.com/

Is it because the www. is the ServerAlias and the non www is the ServerName

Do you have the “mod_speling” loaded in your apache server?

Otherwise everything is case sensitive.
check this: https://stackoverflow.com/questions/14814419/how-do-i-make-urls-case-insensitive-in-linux-server

1 Like

Hi @gmgj

the rule works as defined ( https://check-your-website.server-daten.de/?q=drkpeterhuberblog.com ):

Domainname Http-Status redirect Sec. G
http://drkpeterhuberblog.com/
162.209.11.83 301 https://drkpeterhuberblog.com/ 1.014 A
http://www.drkpeterhuberblog.com/
162.209.11.83 200 0.427 H
https://drkpeterhuberblog.com/
162.209.11.83 200 1.724 B
https://www.drkpeterhuberblog.com/
162.209.11.83 200 1.610 B

The non-www version is redirected, the www version not. You don’t use the L flag, that’s wrong.

Or add the new condition = www.drkpeterhuberblog.com.

The second domain has both required redirects http -> https ( https://check-your-website.server-daten.de/?q=drcassidyboelkblog.com ):

Domainname Http-Status redirect Sec. G
http://drcassidyboelkblog.com/
162.209.11.83 301 https://drcassidyboelkblog.com/ 0.233 A
http://www.drcassidyboelkblog.com/
162.209.11.83 301 https://www.drcassidyboelkblog.com/ 0.217 A
https://drcassidyboelkblog.com/
162.209.11.83 200 1.534 B
https://www.drcassidyboelkblog.com/
162.209.11.83 200 1.290 B

But both domains don’t have a preferred version. So a redirect https + not-preferred-version -> https + preferred version is missing.

1 Like
  1. Thanks. Is this the change I would make in the Virtual Host Files?

Note - system uses name-based virtual hosting**, 1 ip, many domains**

to

RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [l,R=permanent]

  1. Could I remove all the redirect code in the Virtual Hosts files and just do this an .htacess

IfModule mod_rewrite.c>

RewriteEngine on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [l,R=permanent]
#reguired for CodeIgniter Framework stuff
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

# Or  [L,R=301]

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php

My thought is that I also need to Install and activate Apache2 mod_speling
with These directives

LoadModule speling_module modules/mod_speling.so

CheckCaseOnly on CheckSpelling off

NC (NoCase) is the correct switch to ignore upper case.

You can. But later you may have trouble to find the right place. Personally, I would prefer a definition in the correct vHost. This vHost -> redirects, that not.

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