gmgj
July 1, 2019, 6:10am
#1
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
ferdiS
July 1, 2019, 6:34am
#2
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 ):
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 ):
But both domains don’t have a preferred version. So a redirect https + not-preferred-version -> https + preferred version is missing.
1 Like
gmgj
July 1, 2019, 5:22pm
#4
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]
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
gmgj:
END,NE,R=permanent]
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.
system
closed
August 1, 2019, 8:50am
#6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.