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

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

This does redirect a www domain
//all lowercase

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

I checked the with It said its fine, but did not show the 301 permanent redirect that did. What can I do?

Why does this redirect correctly Redirects (no www in domain and lowercase )

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:

1 Like

Hi @gmgj

the rule works as defined ( ):

Domainname Http-Status redirect Sec. G 301 1.014 A 200 0.427 H 200 1.724 B 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 =

The second domain has both required redirects http -> https ( ):

Domainname Http-Status redirect Sec. G 301 0.233 A 301 0.217 A 200 1.534 B 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**


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/

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.