symfony on virtual host document root problem

a 夏天 提交于 2019-12-25 03:41:09

问题


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


回答1:


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';


来源:https://stackoverflow.com/questions/4359756/symfony-on-virtual-host-document-root-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!