Debian Jessie上的Nginx 1.6.2
我想将所有 example.com/forum/ 请求映射到 /path/to/htdocs/phpbb 并切断URI中的/ forum / part . 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 ...
好的,我的配置有什么问题?任何提示?
1 回答
好吧,别名是错误的(重写也是......),但是如果你避免使用try_files并使用if(即使是邪恶的......)它应该可以工作!
phpinfo()看起来很好,但还有一个问题: Is it secure?