2018-11-14 10:52:36 2934次浏览 2条回答 0 悬赏 10 金钱

服务器域名是https开头的,但是用了redirect后确实http的,导致页面404,求大神指教

补充于 2018-11-14 14:25
return $this->redirect('https://'.$_SERVER['HTTP_HOST'].'/admin/site/index');

我目前是这么用的

最佳答案

  • 花椒 发布于 2018-11-14 13:48 举报
        return $this->redirect('https://www.yiichina.com');
    

    你确定这样不行吗?

    4 条回复
    回复于 2018-11-14 13:58 回复

    我知道了,你是项目域名就是https的吧。这个可以用web服务器做重新
    比如 .htaccess

    RewriteEngine on
    RewriteBase /
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
    
    回复于 2018-11-14 14:22 回复

    这是apache服务器的吧,那nginx的呢

    回复于 2018-11-14 14:42 回复

    server {  
        listen  192.168.1.111:80;  
        server_name test.com;  
          
        rewrite ^(.*)$  https://$host$1 permanent;  
    }
    
    回复于 2018-11-14 14:53 回复

    感谢大佬~

  • 回答于 2018-11-15 12:01 举报

    return $this->redirect(Url::toRoute('index/index','https'))->send();

    1 条回复
    回复于 2018-11-24 15:48 回复

    对不起啊,刚刚看到,老铁,你这种也没毛病的,测试过了~多谢~

您需要登录后才可以回答。登录 | 立即注册
听風者
经理

听風者 北京

注册时间:2018-10-12
最后登录:2020-04-08
在线时长:12小时30分
  • 粉丝2
  • 金钱1280
  • 威望20
  • 积分1600

热门问题