Debian Jessie上的Nginx 1.6.2 em> p>
我想将所有 example.com/forum / strong>请求映射到 / path / to / htdocs / phpbb strong>并切断 / forum / em> 参与URI。 Stackoverflow上的某个人推荐“重写” em>解决方案而不是“别名” em>,因为存在一些错误。 p>
示例配置正常工作 - example.com/forum/viewtopic.php strong>执行 脚本 /path/to/htdocs/phpbb/viewtopic.php strong> - 但 example.com / strong>( index.php em>)不起作用 : p>
“/ var / www / html / index.php”失败(2:没有这样的文件或目录) p>
blockquote> \ ñ
在 从服务器块中删除“index” em>行: p>
目录索引“/ path / to / htdocs / phpbb /”被禁止< / p>
blockquote>
将“index” em>和/或“try_files” em>行移动到位置块后 : p>
index.php在没有传递给php-fpm的情况下提供... p>
blockquote>
好的,出了什么问题 用我的配置? 任何提示? p>
div>
server
{
listen [::]:80;
server_name example.com;
root / var / www / html;
index index.php index.html;
#try_files $ uri $ uri / = 404;
位置/论坛/
{
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 ;
}
}
}
code> pre>
Nginx 1.6.2 on Debian Jessie
I want to map all example.com/forum/ requests to /path/to/htdocs/phpbb and cut off the /forum/ part in the URI. Someone on Stackoverflow recommended the "rewrite" solution instead of "alias", because there are some bugs.
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;
}
}
}
The example configuration works fine – example.com/forum/viewtopic.php executes the script /path/to/htdocs/phpbb/viewtopic.php – but example.com/ (index.php) doesn't work:
"/var/www/html/index.php" failed (2: No such file or directory)
After removing the "index" line from server block:
directory index of "/path/to/htdocs/phpbb/" is forbidden
After moving the "index" and/or "try_files" line(s) into the location block:
index.php served without passing over to php-fpm…
Ok, what's wrong with my config? Any hints?