1

symfony1.4 の開発者として、Symfony2 を学ぼうとしています。

さて、すべて正常に動作するローカル マシンで試す代わりに、今日はサーバーでテスト サイトを利用できるようにしたいと考えています。しかし、実際のサイトや実際のサブドメインには展開したくありません。

それが私の質問です。仮想ホストを変更せずに、このテストをサブフォルダーに展開するにはどうすればよいですか?!

利用可能なサイトがあるとしましょうwww.example.com、しかし、symfony テストをここで利用できる (そして正しく動作する) ようにしたいと思います。www.exaple.com/mysymfonytest

誰かがすでにそれをしましたか?

ありがとう...

4

3 に答える 3

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 に答える
0

共有ホスティングでのみ実行している場合。.htaccess を使用してオーバーライド構成を使用できます。オーバーライドを許可するかどうかをプロバイダーに尋ねてから、スクリプトを提供するか、必要なものを伝えます。ホスティングサポートでカバーされていることを願っています.

于 2013-04-27T17:11:49.113 に答える
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 に答える