我使用的是带SSL的Heroku php。一切都设置好了,https运行得很好。我的域名托管在Godaddy上。Heroku作为apache web服务器。但是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
发布于 2013-11-01 16:41:16
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-01 16:41:35
使用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']}"));这两种方法都应该有效。:-)
https://stackoverflow.com/questions/19723313
复制相似问题