简体   繁体   中英

Symfony2 - routing subdomains, but subdomain has a special directory

I read a Google and Symfony2 docs about routing on Subdomains like:

acme_admin_separator:
    path:     /
    resource: "@AcmeAdminSeparatorBundle/Resources/config/routing.yml"
    host:     admin.{domain}
    requirements:
        domain: %domain%

But it should works only, if subdomains are handled by .htaccess . But I have this webhosting hierarchy:

+ /domain.com/
+-- /web/ <-- Here are all my Symfony2 files
+--- /app/
+--- /bundles/
+--- /src/
+--- ...
+-- /sub/ <-- directory for subdomains
+---- /admin/ <-- directory for admin.domain.com subdomain

And I'm asking - is it possible to configure routing to be able to use admin.domain.com as the route for my Symfony2 project without copying all my Symfony2 files to this folder? And if is, should I do something in /admin/ directory?

Your route is right. You must to config your hosting or server for handle all requests for non-existent subdomains *.domain.com .

You have to copy app.php, and paste file in directory like this : /sub/admin/ (change include path in app.php). Or make a blank file and include app.php.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM