Hello.

I want that if a user enters a domain with www or without, with http or https, ip or domain name, it always redirects to the address like https://www.site.ru/path . I found the solutions separately, but I don’t know how to combine everything.

This option redirects from the domain site.com/path to https://www.site.ru/path . But IP does not redirect to the domain.

RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] 

Tell me what you need to fix?

Thank.

    1 answer 1

    Found a solution, it was necessary to add an additional condition on the IP. It seems to work as it should.

     <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{SERVER_PORT} !^443$ [OR] RewriteCond %{HTTP_HOST} ^62\.xxx\.xxx\.234$ [OR] RewriteCond %{HTTP_HOST} ^([^www].*)$ RewriteRule ^(.*)$ https://www.site.ru/$1 [R=301,L] </IfModule>