I have a redirection to index.php in .htaccess, now I'm trying to add 301 redirects (glue the pages), namely redirection from www to without www and from http to https. How to combine these three rules together? So far, I have a message that the server has completed too many redirects. I tried to insert two 301st redirects and before redirecting to index.php and after, the total is one - TOO MANY REDIRECT.
Current data .htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L]
Trying to do something like that ....
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L] RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
DECISION
It turned out that the redirect from http to https comes from the hosting side like that .... so it was worth removing the part that is responsible for the redirect of the protocol - it all worked
RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L]