Nginx How to configure subdomain rewrite to symfony2 specified route

Source: Internet
Author: User
Tags subdomain
The problem is this:

I configured the route in the Symfony2, the prefixes are respectively:

/admin/api/wap...

such as

Now I want to access these three corresponding routes by accessing the three self-domains, respectively

admin.domain.com => /admin/*api.domain.com => /api/*wap.domain.com => /wap/*

At present under the Nginx configuration, but it does not work, want to see you have any ideas and methods of experience, pointing out, is now trapped.

server {    listen 80;    server_name  domain.com ~^(?
  
   
    
   .+)\.domain\.com;    .....    location / {         index app.php;         try_files $uri @rewriteapp;    }    location @rewriteapp {        rewrite ^(.*)$ /app.php/$subdomain$1 last;    }    ......} 
  
   

I hope you are pointing out ... Thank you.

Reply content:

The problem is this:

I configured the route in the Symfony2, the prefixes are respectively:

/admin/api/wap...

such as

Now I want to access these three corresponding routes by accessing the three self-domains, respectively

admin.domain.com => /admin/*api.domain.com => /api/*wap.domain.com => /wap/*

At present under the Nginx configuration, but it does not work, want to see you have any ideas and methods of experience, pointing out, is now trapped.

server {    listen 80;    server_name  domain.com ~^(?
  
   
    
   .+)\.domain\.com;    .....    location / {         index app.php;         try_files $uri @rewriteapp;    }    location @rewriteapp {        rewrite ^(.*)$ /app.php/$subdomain$1 last;    }    ......} 
  
   

I hope you are pointing out ... Thank you.

Without Nginx, this feature is supported by the new routing component
See below Http://symfony.com/doc/current/components/routing/hostname_pattern.html

Nginx default does not support PathInfo, note configuration pathinfo. Symfony routing requires PathInfo mode support.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.