我使用nginx运行Symfony2应用程序,并希望将wordpress安装集成到公共Web文件夹的子文件夹中。
例子:
http://www.example.com -> Symfony 2
http://www.example.com/magazin -> Wordpress
通过Symfony应用程序的原始nginx配置,我可以成功地向wordpress的起始页面以及整个管理区域(包括插件安装等)发出请求。
但是由于我将wordpress配置为对帖子使用自定义url方案“年/月/标题”,所以请求最终以404结尾。我发现,不是wordpress是获取请求的应用程序,而是symfony,它当然是不知道该怎么办。wordpress为帖子创建的URL是正确的(例如http://www.example.com/magazin/2015/12/my-interesing-post)。
是否可以通过扩展nginx配置的方式来处理特定文件夹“ / magazin /”下的所有请求,如果可以,如何进行?
这是我的nginx配置,目前仅处理Symfony2应用程序:
server {
listen *:80;
server_name www.example.de;
index app.php index.php index.html;
access_log /var/log/nginx/www.example.de.access.log combined;
error_log /var/log/nginx/www.example.de.error.log;
location ~ \.php$ {
root /data/www/www.example.de/current/web;
include /etc/nginx/fastcgi_params;
try_files $uri $uri/ /app.php?$query_string;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index app_prod.php;
fastcgi_param X_FORWARD_PORT "80";
fastcgi_param CUSTOMER_ENV customer_default;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
}
location / {
root /data/www/www.example.de/current/web;
index app.php index.php index.html;
try_files $uri $uri/ /app.php?$query_string;
}
}
扩展到马尔科姆斯的解释,这应该做的工作:
(如果您的日志显示默认nginx目录的路径是前置的,则只需再次定义根目录)
location /magazin {
root /data/www/www.example.de/current/web;
index index.php;
try_files $uri $uri/ /magazin/index.php?q=$uri;
}
另外,我不太确定,但我建议在可能提取此路线的其他任何位置块之前插入此位置块(位置/ magazin和之后的位置/)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句