Symfony on a virtual host (root document problem)

I am developing an application in Symfony and on localhost (XAMPP). I want to simulate the same conditions as on a web server.

The web server is configured as follows:

/www   => mydomain.com
/foo   => foo.mydomain.com
/bar   => bar.mydomain.com
...

I will put my Symfony application in /wwwdirectcotry so that it is:

/www
/www/apps
/www/apps/frontend
/www/apps/frontend/...
/www/apps/backend
/www/apps/backend/...
/www/cache
/www/config
... and so on...
/www/web

The fact is that the root directory of the document is still installed in the directory /www, but Symfony expects it in /www/web.
Of course, this will work if I call http://mydomain.com/web, but I think you understand that this is a quiet, stupid decision.

So my question is : Is there a way to change / get around the default root directory settings using .htaccess or something else?

EDIT: I solved it .

+3
3

Symfony, /web . /web URL- . , .

-, DocumentRoot -.

: DocumentRoot .htaccess, , /web, mod_rewrite. kludgy, , , , DocumentRoot.

mod_rewrite, ( , ), , - . , mod_rewrite .

: , . .htaccess /www:

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} !^/web/ 
RewriteRule .* /web/%1 [QSA]

, http://www.domain.com/ http://www.domain.com/web/, .

, - .htaccess Symfony - .

+4

apache config, /www /www/web virtualHost php ( open_basedir) /www .

0

Change the way symfony expects your directory to be named:

// config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->setWebDir($this->getRootDir().'/www/or/whatever/directory');
  }
}
0
source

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


All Articles