在Apache手册的指导下,我或多或少地得到了基本的Apache配置,但是此时重定向规则对我来说有点复杂,所以我希望您能帮助我。
我要做到以下几点:
例如:
我已经掌握了使用这个非常基本的规则的基本知识,但是它只适用于通过http传入的请求,因此通过https引入的非现有子网不会被重新格式化。
<VirtualHost _default_:80>
Redirect permanent / https://domain.tld/
</VirtualHost>希望你能帮助或指点我的方向一个明确的指南(还没有找到一个)。
发布于 2011-12-08 00:26:42
尝试以下mod_rewrite规则:
RewriteEngine On
Options +FollowSymLinks
# force HTTPS for m.example.com
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} =m.example.com
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# only allow m.example.com & example.com -- everything else gets redirected to https://example.com
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} !=m.example.com
RewriteCond %{HTTP_HOST} !=example.com
RewriteRule .* https://example.com%{REQUEST_URI} [R=301,L]
# if still no HTTPS then force it (for any other subdomain)
RewriteCond %{HTTPS} !=on
RewriteRule .* https://example.com%{REQUEST_URI} [R=301,L]
# your other rewrite rules below请记住,为了能够服务器something.example.com,您需要为特定的子域提供适当的SSL证书,或者需要覆盖任何子域的通配符SSL证书。这一点很重要,因为HTTPS的SSL部分在mod_rewrite有机会做任何事情之前就开始工作了(只有当安全连接已经正确建立时,它才会启动)。
https://stackoverflow.com/questions/8424057
复制相似问题