Remove web / app.php in Symfony2

My server has the following directory structure

/srv
   /www
      /site.com
         /symfonysite
         /Other Drupal hosted site files

when I go to site.com, my drupal site opens and I want to have access to my symfony site on site.com/symfonysiteinsteadsite.com/symfonysite/web/app.php

I created the .htaccess file inside /symfonysiteshown below

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /billing/web
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L] 
</IfModule>

But this only eliminates the part of app.php, i.e. site.com/symfonysite/webopens my symfony site and site.com/symfonysitegives an error No route found for "GET /symfonysite/".

What am I doing wrong?

+4
source share
3 answers

Its beauty is that it is highly customizable. You can achieve what you are looking for by following these 4 steps:

  • (, ) symfonysite. . symfonysite.

  • symfonysite/web symfonysite

  • app.php app_dev.php, :

    $loader = require_once __DIR __. '/../app/bootstrap.php.cache';
    require_once __DIR __. '/../app/AppKernel.php';

    $loader = require_once __DIR __. '/project/app/bootstrap.php.cache';
    require_once __DIR __. '/project/app/AppKernel.php';

  • composer.json, "symfony-web-dir": "web"

    "symfony-web-dir": "../",

:

/srv
   /www
      /site.com
         /symfonysite
              /project
         /Other Drupal hosted site files

NB: symfony - - . . . , .htaccess

.htaccess

!!

+6

/srv/www/site.com/symfonysite/web . .htaccess, apache. /etc/apache2/sites-enabled/yourserver.com.conf

<VirtualHost *:80>
    ServerName yourserver.com
    DocumentRoot /srv/www/site.com/symfonysite/web
</VirtualHost>

, rackspace, , , . : P

+3

- . site.com/web/content ln -s symfonysite/web sitesymfony. sitesymfony -, /site.com/web/content/symfonysite/web. .com/sitesymfony app.php site.com/symfonysite/web

+1

Source: https://habr.com/ru/post/1531451/


All Articles