我试图在同一台服务器上configurationCakePHP和一个WordPress的博客。
CakePHP在这里: http : //site.com/
WordPress的博客在这里: http : //site.com/blog/
什么工作:整个CakePHP应用程序,并去/博客/。
什么不行:去/ blog / permalink /。 它提供了一个CakePHP 404页面。
/ blog /可以使用或不使用下面的“#Blogconfiguration”。 我如何使/博客/永久链接/工作? 我习惯与Apache合作。
编辑:有人build议,我的问题是这篇文章的副本,但如果我使用该解决scheme或我的解决scheme(评论#博客configuration)下面给我一个CakePHP 404页面。 这意味着/ blog / permalink /不会击中wordpress的index.php。
upstream backend { server unix:/var/www/apps/appname/tmp/php.sock; } server { listen 80 default; root /var/www/apps/appname/public/app/webroot; index index.php index.html index.htm; server_tokens off; access_log /var/www/apps/appname/logs/access.log; error_log /var/www/apps/appname/logs/error.log; client_max_body_size 20M; rewrite_log on; # Blog config location /blog/ { try_files $uri $uri/ /blog/index.php?$args; } # Not found this on disk? # Feed to CakePHP for further processing! if (!-e $request_filename) { rewrite ^/(.+)$ /index.php last; break; } # Pass the PHP scripts to FastCGI server # listening on 127.0.0.1:9000 location ~ \.php$ { fastcgi_pass backend; fastcgi_index index.php; fastcgi_intercept_errors on; # to support 404s for PHP files not found fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Static files. # Set expire headers, Turn off access log location ~* \favicon.ico$ { access_log off; expires 1d; add_header Cache-Control public; } location ~ ^/(img|cjs|ccss)/ { access_log off; expires 7d; add_header Cache-Control public; } location ~ ^/(php_status|php_ping)$ { fastcgi_pass backend; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; include fastcgi_params; allow 127.0.0.1; deny all; } location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } # Deny access to .htaccess files, # git & svn repositories, etc location ~ /(\.ht|\.git|\.svn) { deny all; } }
这看起来像你的问题。 它重写所有的URL,而不仅仅是CakePHP。 这是最常见的nginx错误configuration之一 。
# Not found this on disk? # Feed to CakePHP for further processing! if (!-e $request_filename) { rewrite ^/(.+)$ /index.php last; break; }
这应该被删除,并replace为您的location /块(你似乎没有,所以创build一个)等价的try_files 。
location / { try_files $uri $uri/ /index.php; }