symfony1configproduction

Configuration problem in my production server in Symfony


Well, I have a shared host and I haven't ssh access. The problem is the server structure and symfony estructure...

Server has this estructure

error/ log/ ... web/

and in web dir we can load web application. Symfony structure is..

app/ .. web/

Well the problem is that with my domain, if I try to access I have to put www.domainname.com/web/ to access at Symfony project....

  1. if I try to copy all web Symfony content to web directory it render first page ok(index.php) but links are wrong because they are www.domainame.com/moduleName/ and this directory does not exist...

  2. if I create an .htacces file in web domain dir... when I put www.domainname.com it redirects me to web automatic but the other links have www.domainname.com/web/moduleName/ in his direction

I want ONLY www.domainname.com/moduleName/... how I can do it?

Edit 1

This is my .htaccess file:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ web/index.php [QSA,L]
</IfModule>

Edit 2

Another problem related:

..
/web/
   app/
   ...
   web/
/blog/

If I modify this, I will have problems accessing to my /blog/ dir?


Solution

  • In order for the /web to be removed from the url you need to use an apache module called mod_rewrite. Like so:

    Options +FollowSymLinks +ExecCGI
    
    <IfModule mod_rewrite.c>
      RewriteEngine On
    
      # uncomment the following line, if you are having trouble
      # getting no_script_name to work
      #RewriteBase /
    
      # we skip all files with .something
      #RewriteCond %{REQUEST_URI} \..+$
      #RewriteCond %{REQUEST_URI} !\.html$
      #RewriteRule .* - [L]
    
      # we check if the .html version is here (caching)
      RewriteRule ^$ index.html [QSA]
      RewriteRule ^([^.]+)$ $1.html [QSA]
      RewriteCond %{REQUEST_FILENAME} !-f
    
      # no, so we redirect to our front web controller
      RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
    

    The docs for this are here.

    The proper way to set up symfony though is to use a Virtual Host which is pointed at the web folder. This will use the web folder as your root and therefore you won't see it in the url.