location / {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://127.0.0.1:4433;
}
apache开了重写,AllowOverride All在.htaccess文件写了
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
由于本机用的wamp,假如我访问了 http://www.example.com/debug在页面中
var_dump(Request::instance()->url())
页面显示就是 E:\wamp\www\gw\application\index\controller\Debug.php:68:string '/debug' (length=6)
但是在服务器上,由于安装了NGINX转发到了APACHE,页面显示内容就为string(16) "/index.php/debug"
如果将代码改成Url::root('/');
var_dump(Request::instance()->url())
页面显示的结果就是string(19) "/index.php?s=/debug"
在登录或者表单请求,没有做路由,/index.php?s=/debug这样的就会提示模块不存在。使用http://www.example.com/debug或http://www.example.com/index.php/debug都可以访问,就是生成URL的时候带index.php,设置Url::root('/');时路由又失效了,表单基本没有做路由,无法提交,会提示系统错误的。
最佳答案
