力SSL和Apache的WWW无 [英] force SSL and no WWW on Apache

查看:133
本文介绍了力SSL和Apache的WWW无的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法想出正确的语法来完成这两个强制SSL和WWW没有

I'm having trouble coming up with the proper syntax to accomplish both forcing the SSL and no WWW.

修改

我已经能够单独完成每项任务,但两者结合时,我发现自己陷入一个循环的重定向

I've been able to accomplish each task separately but when combining the two i find myself stuck in a redirection loop.

工作语法,迫使没有WWW:

working syntax to force no WWW:

RewriteCond %{HTTP_HOST} !^domain\.com$
RewriteRule (.*) http://domain.com/$1 [R=301,L]

我试图强迫任何WWW和SSL

My attempt to force no WWW and SSL

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} !^domain\.com$
RewriteRule (.*) https://domain.com/$1 [R=301,L]

感谢您的任何建议!

Thanks for any suggestions!

推荐答案

有关SSL,你可以使用这样的:

For SSL you could use something like:

Redirect / https://domain.com/

将这只在你的虚拟主机配置为HTTP的部分,而不是HTTPS,不运行的客户端进入无限循环。

Place this only in the section of your virtual host you configure for HTTP, not HTTPS, to not run clients into endless loops.

这篇关于力SSL和Apache的WWW无的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆