【发布时间】:2018-03-19 07:47:10
【问题描述】:
我刚刚在服务器上安装了 SSL 证书。
当前网址:www.example.com
当前工作的 htaccess 文件:
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ^(.*)$ public/ [L]
它正在重定向到 public/index.php。
但问题是当我在 htaccess 中添加 HTTPS 代码时,这个 public/index.php 不起作用。
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?(.*) https://www.example.com/$1 [R]
当我删除公共重定向部分时,HTTPS 正在工作,但未指向 public/index.php。
我怎样才能结合这些规则,以便它将重定向到带有 https url 的 public/index.php。
PS:公共/htaccess
ReWriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
请帮忙!
谢谢
【问题讨论】:
-
是否需要使用.htaccess重定向到HTTPS版本?
-
如果您有其他方法,请!可能会有所帮助
-
你在使用框架吗?或者是否有任何 PHP 文件包含在所有其他文件中?
-
不是我在使用框架。
标签: php .htaccess redirect mod-rewrite https