我在虚拟主机上部署thinkphp,因为虚拟主机上面,默认的首页目录就是wwwroot/下面的,没法修改
我的thinkphp就是在根目录下,因此首页地址是/public/index.php
比如一个方法是/public/index.php/guest/check/ip
里面就一句代码
return $ip = $request->ip();
然后通过www.abc.com/public/index.php/guest/check/ip,能够返回我互联网访问的IP地址
但是,IIS+PHP经过rewrite后
(这里是web.config代码:
<?xm
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="OrgPage" stopProcessing="true">
<match url="^guest/(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^(.*)$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="public/index.php/guest/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
)
然后就可以通过www.abc.com/guest/check/ip访问了,问题来了
这里返回的结果统统都是127.0.0.1
这是为啥呢?
最佳答案