【发布时间】:2016-07-30 23:47:00
【问题描述】:
我正在开始将 WordPress 网站迁移到 Rails 应用程序。迁移需要在接下来的几个月中逐步完成,因此我需要能够并行运行两个站点。在测试环境中使用 fastcgi_intercept_errors 我已经设法让 WordPress 返回的任何 404 错误使用以下配置转发到 Rails 应用程序:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name mydomain.com;
root /var/www/html/wordpress;
index index.php index.html
error_page 500 502 503 504 404 @rails;
location / {
try_files $uri $uri/ /index.php?$args;
recursive_error_pages on;
error_page 404 = @rails;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
error_page 404 = @rails;
}
location @rails{
passenger_enabled on;
passenger_user user;
rails_env development;
root /home/user/rails_app/app/public;
}
}
当 rails 应用程序引用任何 /assets 链接时,问题就出现了,它们总是转发回 rails 应用程序并始终加载应用程序的根位置。
有没有办法解决这个问题,以便资产也被视为 rails 应用程序的一部分?
【问题讨论】:
标签: ruby-on-rails ruby wordpress nginx passenger