symfony 关于虚拟主机文档根问题 [英] symfony on virtual host document root problem

查看:28
本文介绍了symfony 关于虚拟主机文档根问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在虚拟主机上部署 symfony..>

mod_rewrite 将/web URL 转换为域根 URL(domain.com/image.gif 正在内部转换为 domain.com/web/image.gif).

但是由于 web 是从/web 目录内部执行的,Symfony 仍然认为它在那里有文档根目录,并在任何 url_for() URL 前加上/web.

所以当我有路线时:

show_books:网址:/书

..我要求:

url_for('@route_name')

Symfony 正在生成:

/web/books

我无法更改托管行为,我需要将 Web 请求指向 symfony 根路径并在内部重定向到/web 目录,我想让 symfony 忽略它从 |hostname-document-root|/执行的点网络

解决方案

我发现将这段代码插入前端控制器 (/web/index.php) 是一个很好的解决方案:

$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] = '/index.php';

Im trying to deploy symfony on virtual host.

mod_rewrite converts /web URLs to domain root URLs (domain.com/image.gif is turning internaly into domain.com/web/image.gif).

But thanks to web is executed internaly from /web dir, Symfony is still thinking it has document root there and prefixes any url_for() URLs with /web.

So when i have route:

show_books:
  url: /books

..and iam asking for:

url_for('@route_name')

Symfony is generating:

/web/books

I cant change hosting behaviour, i need to have web request pointed into symfony root path and internaly redirected into /web dir and i want to symfony ignore the point it is executed from |hostname-document-root|/web

解决方案

I found the insert of this code into top of my front controller (/web/index.php) as good solution:

$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'] = '/index.php';

这篇关于symfony 关于虚拟主机文档根问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆