AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 105456
In Process
olive
olive
Asked: 2010-01-23 10:28:05 +0800 CST2010-01-23 10:28:05 +0800 CST 2010-01-23 10:28:05 +0800 CST

CakePHP 在使用 nginx 的子目录中(重写规则?)

  • 772

我设法让它工作了一段时间,但是在回到我开始的 cakephp 项目时,似乎我最近对 ​​nginx 所做的任何更改(或者可能是最近的更新)都违反了我的重写规则。

目前我有:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.php index.html index.htm;
        }

        location /basic_cake/ {
            index  index.php;

            if (-f $request_filename) {
              break;
            }
            if (!-f $request_filename) {
              rewrite ^/basic_cake/(.+)$ /basic_cake/index.php?url=$1 last;
              break;
            }
        }

        location /cake_test/ {
            index  index.php;

            if (-f $request_filename) {
              break;
            }
            if (!-f $request_filename) {
              rewrite ^/cake_test/(.+)$ /cake_test/index.php?url=$1 last;
              break;
            }
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

    server {
        listen       8081;
        server_name  localhost;

        root /srv/http/html/xsp;

        location / {
            index  index.html index.htm index.aspx default.aspx;
        }

        location ~ \.(aspx|asmx|ashx|asax|ascx|soap|rem|axd|cs|config|dll)$ {
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

}

我遇到的问题是 CSS 和图像不会从 webroot 加载。相反,如果我访问http://localhost/basic_cake/css/cake.generic.css,我会得到一个页面,告诉我:

CakePHP:快速开发的 php 框架 Missing Controller

错误:找不到 CssController。

错误:在以下文件中创建类 CssController:app/controllers/css_controller.php

注意:如果要自定义这个错误信息,创建app/views/errors/missing_controller.ctp CakePHP:快速开发php框架

有人对如何解决这个问题有任何想法吗?

rewrite nginx cakephp
  • 2 2 个回答
  • 4972 Views

2 个回答

  • Voted
  1. olive
    2010-01-25T13:49:22+08:002010-01-25T13:49:22+08:00

    我最终使用了一种解决方法。安装 Apache 并使用 proxy_pass nginx 指令将流量从特定文件夹推送到 Apache。

    • 1
  2. seanl
    2010-01-26T13:22:32+08:002010-01-26T13:22:32+08:00

    我认为问题是你的重写规则应该是这样的

    location / {
        root /home/public_html/sub.example.com/cake/app/webroot;
        index index.php;
    
        if (-f $request_filename) {
            break;
        }
        if (!-f $request_filename) {
            rewrite ^/(.+)$ /index.php?url=$1 last;
            break;
        }
    }
    

    我有一个类似的问题,通过这个cakephp & nginx config/rewrite rules解决了

    • 1

相关问题

  • nginx 工作进程的数量

  • 使用Passenger时使用Nginx over Apache with Rails的优缺点是什么

  • 阿帕奇的替代品

  • 如何强制我的网址始终以 www 开头?

  • mod_rewrite 不转发 GET 参数

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve