thinkphp U方法生成有关问题

WBOY
Release: 2016-06-13 12:01:13
Original
994 people have browsed it

thinkphp U方法生成问题。
我的表单中提交是这样写的:


提交后本应该跳转到:http://1121.87.98.198/index.php/Login/login
现在确跳到提交后本应该跳转到:http://localhost/index.php/Login/login

我服务器配置文件中'DB_HOST' => 'localhost',难道U方法还要单独设置吗?
用的是Nginx服务器

现在问题是要怎么配置U让localhost变成ip?
------解决方案--------------------
是不是改动过U函数?看这里

<br />    if($domain) {<br />        $url   =  'http://'.$domain.$url;<br />    }else{<br />        $url   =  "http://".$_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']==80?'':':'.$_SERVER['SERVER_PORT']).$url;<br />    }<br />
Copy after login


生成的url永远是绝对地址,而我印象中他一直是相对路径,你把else删了吧
------解决方案--------------------
本帖最后由 xuzuning 于 2014-06-28 11:25:00 编辑 他最后是 
    if($domain) {
        $url   =  'http://'.$domain.$url;
    }else{
        $url   =  "http://".$_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']==80?'':':'.$_SERVER['SERVER_PORT']).$url;
    }
你调用时 U(GROUP_NAME.'/Login/login') 没有 $domain
所以走 else 分支,即你用什么域名访问就是什么域名
你若想自己定义则
U(GROUP_NAME.'/Login/login', '', true, false, $IP)
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!