1

作为一个 symfony1.4 的开发者,我正在努力学习 Symfony2。

现在,我不想在我的本地机器上尝试一切正常,今天我想让我的测试站点在我的服务器上可用。但我不想将它部署在真实站点或真实子域上。

这就是我的问题:如何在不修改虚拟主机的情况下将此测试部署在子文件夹上?!

假设我有一个可用的站点,www.example.com但是我想在这里提供我的 symfony 测试(并且工作正常)www.exaple.com/mysymfonytest

有人已经这样做了吗?

谢谢...

4

3 回答 3

0

In my opinion that is not really a symfony related question.

Depending on your webserver you could configure an alias where which url should point.

In Apache you specify your document root, where you put your sf2 installation, and then define an alias which would be /mysymfonytest pointing to that document root.

Alternatively you could specify your document root, leave the url be and define a prefix for all routes in symfony, which you would do in your routing configuration.

I strongly recommend configuring your webserver though.

For example in apache:

<VirtualHost *:80>
    DocumentRoot /var/www/mysymfonytest
    Alias /mysymfonytest /var/www/mysymfonytest
    <Directory /var/www/mysymfonytest/web>
            AllowOverride None
            Order allow,deny
            Allow from all

            #Allow from <SUPPORT>
            RewriteEngine On
            RewriteBase /mysymfonytest
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ /app.php [QSA,L]
    </Directory>
</VirtualHost>

Alternatively, if you cannot add the VHost: How to add a prefix to all my routes

于 2013-04-24T08:55:01.593 回答
0

如果您只在共享主机上运行。您可以使用 .htaccess 来使用覆盖配置。询问您的提供者是否允许覆盖,然后向他们提供脚本或告诉他们您想要什么。希望这涵盖在您的托管支持中。

于 2013-04-27T17:11:49.113 回答
0

在(根目录)下创建一个子目录/并调用它,mysymfonytest然后将您的 symfony2 项目放入mysymfonytest.

将 .htaccess 文件添加到 mysymfonytest文件夹并放入其中:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ web [L]

</IfModule>

或者您可以只创建一个名为的文件index.html并使其指向app.php

于 2013-04-24T16:16:53.847 回答