Apache and .htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]Behind a proxy or CDN the condition may differ; follow the provider's documentation.
On ordinary hosting this setting is often included in the plan. You avoid editing server files yourself and risking the availability of the site.
Copy the message, replace the domain and state whether the primary version uses WWW.
Hello, A working SSL certificate is already installed for example.com. Please configure a permanent 301 or 308 redirect from every HTTP URL to its corresponding HTTPS URL, preserving the path and query string. The primary hostname is example.com without www. Please tell me what was changed when the work is complete.
These examples are for the server owner or the person responsible for configuration. State the primary hostname explicitly.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]Behind a proxy or CDN the condition may differ; follow the provider's documentation.
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}Run sudo nginx -t before reloading Nginx.
robots.txt redirects too.The final group is not repaired by the HTTP → HTTPS rule and should be handled as separate work when present.