Search code examples
phpsymfonysymfony-2.5

Deploying Symfony 2.5.3 website to production server


I have been working on a website in development environment built on top of Symfony framework and now it is time to deploy it to live site, in development environment we run the command php app/console server:run to run the website but I am not sure what needs to be done to make the user see website contents on live server, after i uploaded the code to live server all I see is root directory structure of Symfony, I have gone through How to Deploy a Symfony Application and i am scratching my head as there is got to be more to it because after following the steps no difference was made and i still see directory structure.

I did notice that when I click on the web folder I see the website so I created the following .htaccess file which works but the URL looks like www.domain.com/web how can i just make it www.domain.com

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

I will really appreciate if I can get some help here, if it helps I am trying to deploy on Linux based server using Apache.

SOLUTION Add the following in your .htaccess file and it will work as this is what solved my problem and please remember to clear your browser cache as well

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
</IfModule>

Solution

  • After following all the How to deploy a Symfony App, in the root of your Symfony application create .htaccess file and add the following code in it, this is what solved my problem.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.domain.com$
    RewriteCond %{REQUEST_URI} !web/
    RewriteRule (.*) /web/$1 [L]
    </IfModule>