[英]CodeIgniter calls /index.php instead of /basefolder/index.php , on Nginx?
I am running CodeIgniter 3.0.6 in an Nginx server and subpaths end up serving /index.php
, rather than /<installdir>/index.php
. 我在Nginx服务器上运行CodeIgniter 3.0.6,并且子路径最终提供
/index.php
而不是/<installdir>/index.php
。 So, if I ask for /CodeIgniter-3.0.6/home/
I get served the /index.php
page instead, rather than /CodeIgniter-3.0.6/index.php
as expected. 因此,如果我要求
/CodeIgniter-3.0.6/home/
,则可以使用/index.php
页面,而不是按预期的方式使用/CodeIgniter-3.0.6/index.php
。 Note, that my CodeIgniter application will eventually reside in /2016/
. 请注意,我的CodeIgniter应用程序最终将驻留在
/2016/
。
I suspect this is down to a misconfiguration of my Nginx install, rather than something CodeIgniter related? 我怀疑这归因于我的Nginx安装的错误配置,而不是与CodeIgniter相关的东西? My Nginx install is running on Ubuntu 16.04.
我的Nginx安装在Ubuntu 16.04上运行。 The contents of the /etc/nginx/sites-enabled/default are:
/ etc / nginx / sites-enabled / default的内容为:
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
include fastcgi.conf;
}
Is there something else I should be changing? 还有什么我应该改变的吗?
If your server has a single application with the main entry point at /CodeIgniter-3.0.6/index.php
, you should probably set your locations like this: 如果您的服务器只有一个应用程序,其主要入口位于
/CodeIgniter-3.0.6/index.php
,则可能应这样设置位置:
location / {
try_files $uri $uri/ /CodeIgniter-3.0.6/index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
include fastcgi.conf;
}
That way, any URI that is not a match for a resource file or a .php
file, will be routed to your applications default entry point /CodeIgniter-3.0.6/index.php
. 这样,任何与资源文件或
.php
文件都不匹配的URI都将被路由到应用程序的默认入口点/CodeIgniter-3.0.6/index.php
。
However, if there is more than one application, such that /index.php
and /CodeIgniter-3.0.6/index.php
are two distinct entry points, you may want to set up locations for each application, possibly like this: 但是,如果有多个应用程序,例如
/index.php
和/CodeIgniter-3.0.6/index.php
是两个不同的入口点,则可能需要为每个应用程序设置位置,可能是这样的:
location / {
try_files $uri $uri/ /index.php;
}
location /CodeIgniter-3.0.6 {
try_files $uri $uri/ /CodeIgniter-3.0.6/index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
include fastcgi.conf;
}
That way, only URIs that begin with /CodeIgniter-3.0.6
will be routed to that application's default entry point. 这样,只有以
/CodeIgniter-3.0.6
开头的URI才会被路由到该应用程序的默认入口点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.