的.htaccess追加的https:// WWW [英] .htaccess for appending https://www
问题描述
我已经搜索相当一段时间得到解决或提示我的查询,但没有发现任何有价值的。基本上我有我的应用程序,它是SSL安全。所有我想要的是
I have searched for quite sometime to get a solution or a hint to my query but didnt find anything valuable. Basically i have my application which is SSL secured. All i want is that
-
如果用户尝试打开应用程序,而不HTTPS和www,它会自动追加
的https:// WWW
如果用户输入 https://mydomain.com
,应改为 HTTPS://www.mydomain .COM
如果用户输入 www.mydomain.com
,应改为 https://www.mydomain.com
我理解这一点可以通过htaccess的实现,但我有很多懵懂有关这些文件的编写方式。
I understand this can be achieved through .htaccess but i am a lot ignorant about the way these files are written.
任何帮助将是非常美联社preciated。
Any help will be highly appreciated.
推荐答案
到的httpd.conf
启用了mod_rewrite和.htaccess,然后把这个code在< $ C C>的.htaccess $ DOCUMENT_ROOT
目录下:
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
这篇关于的.htaccess追加的https:// WWW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!