Search code examples
.htaccesssubdomainsymfonyinternal-server-error

Subdomain in Symfony gives Internal Server Error


I have a Symfony project (example.com) and added a subdomain (demo.example.com) pointing to the same app. The subdomain gives an Internal Server Error. The error log shows: AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary.

I set op my routing.yml like this:

account_homepage:
    path:     /
    host:     "{subdomain}.{domain}"
    defaults:
        _controller: AppBundle:Default:loginRedirect
    requirements:
        subdomain: demo|myaccount

homepage:
    path:     /
    defaults:
        _controller: AppBundle:Default:loginRedirect

Based on the Symfony docs in How to Match a Route Based on the Host. Similar questions seem to point to the .htaccess file but I used the htaccess file shipped with Symfony:

<IfModule mod_authz_core.c>
    Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
    Order deny,allow
    Deny from all
</IfModule>

What is the way to go to get subdomains working in my project?


Solution

  • Changing the subdomains to Domain Pointers in DirectAdmin so subdomain.example.com becomes an alias of example.com was the solution for my project.