ZF2 - 始终使用 https 打开?
ZF2 - Always open with https?
我有关注 .htaccess,但我的 ZF2 网站始终不会转到 https,而是仅保持为 http。
当我以 www.example.com or example.com or http://www.example.com or example.com/controller
的身份打开网站时,我总是需要它 https://www.example.com
而不是留在 http://
中。
为什么以下内容不起作用?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
以下似乎有效。我在说什么
如果访问者访问以下站点,则始终将其覆盖为 https://
example.com
www.example.com
http://example.com
http://www.example.com
example.com/bla-bla
www.example.com/bla-bla
http://example.com/bla-bla
http://www.example.com/bla-bla
如果访问者有 https:// 则忽略 https 覆盖
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
我有关注 .htaccess,但我的 ZF2 网站始终不会转到 https,而是仅保持为 http。
当我以 www.example.com or example.com or http://www.example.com or example.com/controller
的身份打开网站时,我总是需要它 https://www.example.com
而不是留在 http://
中。
为什么以下内容不起作用?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
以下似乎有效。我在说什么
如果访问者访问以下站点,则始终将其覆盖为 https://
example.com
www.example.com
http://example.com
http://www.example.com
example.com/bla-bla
www.example.com/bla-bla
http://example.com/bla-bla
http://www.example.com/bla-bla
如果访问者有 https:// 则忽略 https 覆盖
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]