我设法得到这个工作了一段时间,但返回到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和图像不会从Web根加载。 相反,如果我访问http://localhost/basic_cake/css/cake.generic.css ,我得到一个页面告诉我:
CakePHP:快速开发php框架失踪控制器
- 这是不安全的Apache重写规则?
- 无法search“。” 使用htaccess
- 用TomCat重写URL
- 在Linux上的ASP.NET,URL重写和线程?
- IIS 7 URL重写:不适用于redirecturl的C:1反向引用
错误:无法findCssController。
错误:在文件:app / controllers / css_controller.php中创build类CssController
注意:如果你想自定义这个错误信息,创buildapp / views / errors / missing_controller.ctp CakePHP:快速开发php框架
有没有人有任何想法如何解决这个问题?
我结束了使用一个解决方法。 安装了Apache,并使用proxy_pass nginx指令将stream量从特定文件夹推送到Apache。
我认为问题是你的重写规则应该是这样的
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&nginxconfiguration/重写规则解决