Symfony4总是重定向到index.php

时间:2018-03-19 19:25:14

标签: php linux apache symfony

我正在尝试部署我的Symfony 4应用。我从目录启动了symfony服务器并且正在监听

  

127:0.0.1:888

我的/etc/apache2/sites-enabled/nameofdomain.conf是:

Listen 888
<VirtualHost *:888>
   ServerName domain.com
   ServerAlias domain.com

   DocumentRoot /var/www/html/Project/public
    <Directory /var/www/html/Project/public>
        AllowOverride All
        Require all granted
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php [QSA,L]
        </IfModule>
    </Directory>

    <Directory /var/www/html/Project/public/bundles>
        <IfModule mod_rewrite.c>
            RewriteEngine Off
        </IfModule>
    </Directory>
    ErrorLog /var/log/apache2/domain.com_error.log
    CustomLog /var/log/apache2/domain.com_access.log combined
</VirtualHost>

当我输入域名时:888我总是被重定向到域名:888 / index.php /有错误

  

找不到&#34; GET /&#34;

的路线

当我输入域名时:888 / correctPath我遇到了apache错误&#39;找不到&#39;。

我有Apache 2.4.18和Ubuntu 16.04。 你能帮我解决一下我应该如何提供app?

1 个答案:

答案 0 :(得分:0)

第一

composer require symfony/apache-pack

然后

<VirtualHost *:888>
    ServerName domain.tld
    ServerAlias www.domain.tld

    DocumentRoot /var/www/project/public
    <Directory /var/www/project/public>
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>