以下Nginx配置似乎无法正常工作,并在访问http://example.com/xml_apps/时返回404错误,但joomla网站可以从根URL http://example.com正常工作
UPDATE
看起来请求现在发送到codeigniter应用程序,因为404错误来自CI应用程序.
http://example.com/xml_apps/index.PHP/xmlengine/jmprovince?category=1&count=10
我们是否需要某种配置来添加codeigniter级别?让控制器/动作工作.
server {
listen 80;
root /home/ubuntu/websites/example.com/public_html;
index index.html index.htm index.PHP;
server_name example.com;
location / {
try_files $uri $uri/ /index.PHP;
}
location /xml_apps/ {
if ($request_uri ~ "^system.*"){
rewrite ^/xml_apps/(.*)$/xml_apps/index.PHP?/$1 last;
}
if (!-e $request_filename){
rewrite ^/xml_apps/(.*)$/xml_apps/index.PHP?/$1 last;
}
}
location ~ \.PHP${
try_files $uri =404;
fastcgi_pass unix:/var/run/PHP5-fpm.sock;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
}
}
最佳答案
至于CodeIgniter级别设置,请编辑application / config / config.PHP文件(同时阅读config.PHP中的注释)
$config['base_url'] = 'http://example.com/xml_apps';
如果您想要不错的网址,请同时使用以下代码
$config['index_page'] = '';
至于Nginx设置,请访问Nginx community – 这一切都很好地解释了.
编辑
改变Nginx设置
# removes access to "system" folder,also allows a "System.PHP" controller
if ($request_uri ~* ^/system)
{
rewrite ^/(.*)$/index.PHP?/$1 last;
break;
}
# unless the request is for a valid file (image,js,css,etc.),send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$/index.PHP?/$1 last;
break;
}