Matt
Matt

Reputation: 5567

Symfony2 on GoDaddy Shared with multiple sites

I'm close to getting Symfony2 working a GoDaddy shared hosting plan (with multiple sites).

So I have the following accessible via web/ftp (note, there is another directory level above this I can access over SSH):

/              <-- dummy domain points here to "hide" it sort of
----/SiteA     <-- sitea.com (Wordpress, working fine)
----/SiteB     <-- siteb.com (Wordpress, working fine)
----/SiteC     <-- sitec.com (Wordpress, working fine)
----/Symfony
--------/app
--------/web   <-- symfonysite.com
------------/.htaccess
------------/app.php

I can access the default controller at symfonysite.com just fine. But when I click on a link (example symfonysite.com/my/page), I get a 500 error.

When I try going to symfonysite.com/app.php it's even weirder. I end up on symfonysite.com/Symfony/web.

Clearly something is not right in my .htaccess, because it is not rewriting properly. Somehow it is relative to web root, not to the root of the particular parked domain. I'm guessing this is an easy fix, but I'm not experienced with .htaccess (this is just the default from 2.3). Here it is below, with comments removed:

DirectoryIndex app.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>

Upvotes: 2

Views: 1135

Answers (1)

Matt
Matt

Reputation: 5567

As I was posting, I figured out the answer by reading the comments in .htaccess more closely. Posting this Q&A in case it helps others.

The problem is here:

# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the app.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]

I believe that is changing my rewrites to be /Symfony/web/app.php instead of /app.php. Commenting out those lines worked.

Upvotes: 2

Related Questions