0

我正在使用带有 SSL 的 Heroku php。一切都已设置好,https 完美运行。我的域名托管在 Godaddy。Heroku 作为 apache 网络服务器。但http://mysite.com, www.mysite.com 不会重定向到https://www.mysite.com 这是我想要的。

我已将 .htaccess 文件更改为以下

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} protected [NC,OR]
RewriteCond %{REQUEST_URI} protected2 [NC,OR]
RewriteCond %{REQUEST_URI} protected3 [NC]

我还将域转发到https://www.mysite.com

4

2 回答 2

0
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context

资源

于 2013-11-01T08:41:15.927 回答
0

使用 htaccess 文件:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

使用PHP来指导:

  exit(header("location: https://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}"));

两者都应该工作。:-)

于 2013-11-01T08:41:34.863 回答