4

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 up and I want to be able to access my symfony site on site.com/symfonysite instead of site.com/symfonysite/web/app.php

I created an .htaccess file inside /symfonysite shown below

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

But this only gets rid of the app.php part, i.e. site.com/symfonysite/web opens my symfony site and site.com/symfonysite gives No route found for "GET /symfonysite/" error.

What am I doing wrong?

1

3 Answers 3

6
+50

Its the beauty of symfony that it is highly configurable. You can achieve what you are looking for by following the simple 4 steps:

  1. Create a directory(say project) and put all the content of symfonysite there. You can put this directory any where you like. For simplicity we are going to create the directory in your symfonysite dir.

  2. Move all content of your symfonysite/web to symfonysite

  3. Edit the app.php and or app_dev.php to modify two line as follow:

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

    to

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

  4. Edit composer.json file to update the value of "symfony-web-dir": "web" and change it to

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

Your modified directory structure may look like:

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

NB: For security reason symfony suggest to expose only the web directory to a web accessible path. You can put the project directory any where you like. Just need to update the path as per your locations. To give this set-up a little more security you can put a .htaccess file in the project directory

.htaccess

Deny from all

Enjoy!!

Sign up to request clarification or add additional context in comments.

1 Comment

You can find reference documentation here
3

You need to make /srv/www/site.com/symfonysite/web the document root of the project. This can't be done with .htaccess so you need to change apache virtual host config. This usually lives in /etc/apache2/sites-enabled/yourserver.com.conf

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

I'm not sure how rackspace sites work, maybe best to open a support ticket with them if you are unable to change these settings. I head they have Fanatical Support :P

1 Comment

this doesnt seem to address the issue, the OP site.com already has a document root of /srv/www/site.com. changing that will make the drupal site inaccessible on that domain. You should simply configure symfony as xiisea suggest.
1

The best approach IMHO is to use symlinks. In the site.com/web/content directory you need to run ln -s symfonysite/web sitesymfony. It will create symlink sitesymfony in your web-root that points to /site.com/web/content/symfonysite/web folder. Then your site.com/sitesymfony will call app.php from site.com/symfonysite/web

2 Comments

I'm using Rackspace Cloud Sites and Symlinks aren't supported unfortunately.
UPDATE: Using Rackspace Cloud Server now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.