加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

Nginx在子目录中配置Joomla和Codeigniter

发布时间:2020-12-13 21:34:59 所属栏目:Nginx 来源:网络整理
导读:以下nginx配置似乎无法正常工作,并在访问http://example.com/xml_apps/时返回404错误,但joomla网站可以从根URL http://example.com正常工作 UPDATE 看起来请求现在发送到codeigniter应用程序,因为404错误来自CI应用程序. http://example.com/xml_apps/index.

以下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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读