I would like my site to be accessed by https only. How to force a website to use https by htaccess settings by redirecting http requests to the corresponding https ones?
我希望仅通过https访问我的网站。 如何通过将http请求重定向到相应的https请求来通过htaccess设置强制网站使用https?
You can check the method of redirecting http to https at:
您可以在以下位置查看将http重定向到https的方法:
https://www.systutorials.com/qa/1033/how-to-redirect-http-to-https-in-apache-with-mod_rewrite
https://www.systutorials.com/qa/1033/how-to-redirect-http-to-https-in-apache-with-mod_rewrite
If you would like to have a 301 redirect, you can use the following .htaccess file:
如果您想进行301 重定向 ,则可以使用以下.htaccess文件:
# force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
翻译自: https://www.systutorials.com/how-to-force-a-website-to-use-https-by-htaccess-settings/