I want to redirect https://www.example.com to https://example.com. I followed this answer but it doesn't work. By the way, ErrorDocument 404
doesn't work as well.
What do have I have to do? Here is my file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
AddType application/x-httpd-php html
ErrorDocument 404 https://kocer.org/index.php?p=notfound
</IfModule>