0

Let's say I have a Symfony webapp and it is in a subfolder of my webroot

path/to/root/<subfolder>/Symfony/

So if I would want to call my page I have to enter

http://host.tld/<subfolder>/Symfony/web

But as you can imagine I would like everyone just to call

http://www.host.tld/

I know that I can use the webserver's settings (e.g. define root directory, set alias etc.). Thus I derive two questions:

  1. Where do I tell Symfony that this is the base of all to be created links? And

  2. Does Symfony provide a native function or configuration, where I can set this up without having to change my webserver's configuration?

4

2 回答 2

4

专用服务器 :

如果您在专用的 debian 服务器(使用 apache)上,您可能知道什么是虚拟主机。

您需要创建一个 Vhost 并将域指向 Symfony 项目的 web 文件夹以封装用户:

纳米 /etc/apache2/sites-enabled/host.tld :

<VirtualHost *:80>
    ServerName host.tld
    DocumentRoot /home/sybio/www/mywebsite/Symfony/web

    <Directory "/home/sybio/www/mywebsite/Symfony/web">
        DirectoryIndex app.php
        Options -Indexes FollowSymLinks SymLinksifOwnerMatch
        AllowOverride All
        Allow from All
    </Directory>
</VirtualHost>

然后测试apache配置:

apache2ctl configtest

如果没有错误重启:

apache2ctl restart

而已 !

共享主机 :

在许多托管服务商中,例如 OVH,您可以通过管理面板配置目标文件夹(网络目录)!如果你不能,这很容易:

1)在共享主机的根目录中添加 Symfony 结构

2)用你的主机使用的重命名web / dir(通常是“www”或“public”)

3)覆盖 Sf 配置说“web”目录现在命名为“www”:http ://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html#override-the-web-directory

于 2013-08-08T15:24:11.527 回答
1
  1. 将 Symfony 文件夹及其所有内容移动到其他位置,例如/home/work/Symfony

  2. 复制Symfony/web/.htaccessapp.phphttp://www.host.tld/(即wwwpublic-htmlhtdocs

  3. 编辑app.php并调整 require 语句以指向/home/work/Symfony/app

  4. app/console assets:install http://www.host.tld/

此时,应用程序应该在www.host.tld假设您的缓存权限设​​置正确的情况下运行。路线中将包含生成的所需路径。

无需更改您的 Web 配置。

于 2013-08-08T15:17:52.487 回答