【发布时间】:2017-12-07 15:05:48
【问题描述】:
我的文件结构是这样的:
nginx 默认根目录:
~/marketplace/
正在尝试创建别名:
~/marketplace/endpoints/sdk/tag.php
在 URI 位置 /tagframe.htm 下
基本上,当我转到 http://marketplace/tagframe.htm?t=1&c=2 时,我需要将请求路由到 ~/marketplace/endpoints/sdk/tag.php 并保留 $query_string
虽然这有效:
location /tagframe.htm {
try_files $uri /endpoints/sdk/tag.php$is_args$args;
}
它使用文件的实际路径 (tag.php) 填充 PHP_SELF,而不是我需要的 URI 部分 (tagframe.htm) - 让它认为 /tagframe.htm 是一个真实文件并填充它进入 PHP_SELF。
例如,Lighttpd 通过它的
alias.url /tagframe.htm => ~/marketplace/endpoints/sdk/tag.php
PHP_SELF 显示 /tagframe.htm
企图欺骗它的是:
location /tagframe.htm {
alias $root_path/endpoints/sdk;
rewrite (.*) /endpoints/sdk/tag.php?$query_string;
include php-fpm;
}
P.S $root_path 是我的项目根目录(hacky)的映射默认值,php-fpm 文件是默认的fast_cgi 代理到php:
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
任何想法我做错了什么?
【问题讨论】:
标签: nginx php lighttpd mod-alias