【发布时间】:2015-06-04 23:51:32
【问题描述】:
Debian Jessie 上的 Nginx 1.6.2
我想将所有 example.com/forum/ 请求映射到 /path/to/htdocs/phpbb 并切断 /forum/ em> 部分在 URI 中。 Stackoverflow 上有人推荐了 "rewrite" 解决方案,而不是 "alias",因为存在一些错误。
server
{
listen [::]:80;
server_name example.com;
root /var/www/html;
index index.php index.html;
#try_files $uri $uri/ =404;
location /forum/
{
root /path/to/htdocs/phpbb;
rewrite ^/forum/(.*)$ /$1 break;
location ~ .+\.php$
{
rewrite ^/forum/(.*)$ /$1 break;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
}
示例配置工作正常 - example.com/forum/viewtopic.php 执行脚本 /path/to/htdocs/phpbb/viewtopic.php - 但是 example.com/ (index.php) 不起作用:
“/var/www/html/index.php”失败(2:没有那个文件或目录)
从服务器块中删除 "index" 行后:
“/path/to/htdocs/phpbb/”的目录索引被禁止
将 "index" 和/或 "try_files" 行移动到位置块后:
index.php 没有传递给 php-fpm…
好的,我的配置有什么问题?有什么提示吗?
【问题讨论】: