Website is not obeying rewrite .htaccess data

#1
I have a website litti.biz, which has SSL certificate. My problem is website is getting redirected to www.litti.biz, even if I have set rewrite rule in .htaccess correctly. Following is content of .htaccess. All other websites are working correctly, only this website has the issue. please advise
Apache config:
Header set Strict-Transport-Security "max-age=31536000" env=HTTPS
Header set Cache-Control "max-age=2628000, public"

Options -Indexes
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA,L]
RewriteRule database.js - [F]
RewriteRule cache.json - [F]

Header always edit Set-Cookie (.*) "$1; HTTPOnly"
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options: nosniff
Header always append X-Frame-Options SAMEORIGIN
Header set Referrer-Policy: strict-origin-when-cross-origin
 

Cold-Egg

Administrator
#2
So the site URL you want to use is litti.biz, not www.litti.biz. But the following rules mean, if the URL does not start from www, then redirect to www.
```
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
```
 
#3
So the site URL you want to use is litti.biz, not www.litti.biz. But the following rules mean, if the URL does not start from www, then redirect to www.
```
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
```
Thank you for clarification, what should be correct rewrite rule to forward www to non www address?
 

Cold-Egg

Administrator
#4
Try to replace
Code:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
with
Code:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.
RewriteRule ^(.*)$ https://litti.biz/$1 [R=301,L]
 
#5
Try to replace
Code:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
with
Code:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www.
RewriteRule ^(.*)$ https://litti.biz/$1 [R=301,L]
Thank you, its working, much appreciated!
 
Top