php - nginx 如何配置 subdomain rewrite到symfony2指定路由
PHP中文网
PHP中文网 2017-04-10 15:22:48
0
2
564

问题是这样的:

我在symfony2当中配置了路由,前缀分别是分别是:

/admin
/api
/wap
...

等。

现在我想通过访问三个自域名去访问这分别三个对应的路由,分别是

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

目前在nginx下配置了,但是却不起效,想看看各位对这个有什么见解和方法经验,指点一下,现在被困住了。

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

    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$subdomain$1 last;
    }
    ......
} 

望各位指点...谢谢。

PHP中文网
PHP中文网

认证0级讲师

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!