Php 使用nginx将请求重写到不同的enpoint
我在joomla上有一个站点,它的子文件夹文件夹中有独立的php文件Php 使用nginx将请求重写到不同的enpoint,php,nginx,Php,Nginx,我在joomla上有一个站点,它的子文件夹文件夹中有独立的php文件 location / { try_files $uri $uri/ /index.php?q=$request_uri; } location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_pass backend;
fastcgi_read_timeout 90;
}
现在我想做这样的事情:
location ~ /forder/(.*)\.php {
try_files $uri /folder/app.php?controller=$1;
}
当我转到nginx时,发送该文件的源代码。
我哪里出错了?我的解决办法是
if (!-e $request_filename){
rewrite /folder/(.*)\.php /folder/app.php?controller=$1 last;
}
在
server
section中,文档根是什么(root
指令的值)以及与之相关的script.php
文件在哪里?root-/var/www,file-/var/www/folder/script.phpTry:location/folder/{try\u files$uri/folder/app.php?controller=$1;}
谢谢你,但它没有帮助。我找到了另一个解决办法。