我正在使用Nginx bitnami codeigniter服务器。
在根文件夹中已存在现有codeigniter项目的情况下,现在有必要将新应用程序添加到子文件夹中。 在apache中,只需创建一个子文件夹并将codeigniter复制到其中,但在nginx中,它继续作为root应用程序连接,将子文件夹视为控制器,并发生404错误。 我应该如何设置?
这是我的Bitnami配置文件。
server {
listen 80;
server_name localhost;
include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";
include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf";
## Root and index files.
root /opt/bitnami/nginx/html;
index index.php index.html index.htm;
## If no favicon exists return a 204 (no content error).
location = /favicon.ico {
try_files $uri =204;
log_not_found off;
access_log off;
}
## Don't log robots.txt requests.
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
## Try the requested URI as files before handling it to PHP.
location / {
proxy_buffers 8 1024k;
proxy_buffer_size 1024k;
## Regular PHP processing.
location ~ \.php$ {
try_files $uri =404;
#fastcgi_pass php_processes;
fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
## Static files
location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
expires max;
log_not_found off;
## No need to bleed constant updates. Send the all shebang in one
## fell swoop.
tcp_nodelay off;
## Set the OS file cache.
open_file_cache max=1000 inactive=120s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
}
## Keep a tab on the 'big' static files.
location ~* ^.+\.(?:ogg|pdf|pptx?)$ {
expires 30d;
## No need to bleed constant updates. Send the all shebang in one
## fell swoop.
tcp_nodelay off;
}
} # / location
if (!-e $request_filename ) {
rewrite ^(.*)$ /index.php last;
}
}
并且此代码将所有路径重定向到indx.php。
if (!-e $request_filename ) {
rewrite ^(.*)$ /index.php last;
}
谢谢。