【问题标题】:Symfony4 redirects always to index.phpSymfony4 总是重定向到 index.php
【发布时间】:2018-08-28 11:29:23
【问题描述】:

我正在尝试部署我的 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>

当我输入 domain:888 时,我总是被重定向到 domain:888/index.php/ 并出现错误

找不到“GET /”的路由

当我输入 domain:888/correctPath 我有 apache 错误“未找到”。

我有 Apache 2.4.18 和 Ubuntu 16.04。 您能帮我如何为应用提供服务吗?

【问题讨论】:

  • 您可以从删除Allow from All 开始,因为这是Require all granted 的APache 2.2 语法
  • 你应该被定向到 index.php 那是 Symfony 的 MVC 的 Front Controller
  • 你有申请吗?如果没有尝试安装github.com/symfony/demo

标签: php linux apache symfony


【解决方案1】:

第一

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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-15
    • 1970-01-01
    • 1970-01-01
    • 2018-04-03
    • 2013-01-21
    • 2014-08-31
    • 2023-04-05
    • 1970-01-01
    相关资源
    最近更新 更多