简体   繁体   English

从子域重定向到Dotcloud上的文件夹

[英]Redirecting from subdomain to folder on Dotcloud

Is it possible to redirect from a subdomain to a folder using the application nginx.conf on Dotcloud? 是否可以使用Dotcloud上的应用程序nginx.conf从子域重定向到文件夹?

I want to redirect http://blog.domain.com to http://www.domain.com/blog 我想将http://blog.domain.com重定向到http://www.domain.com/blog

I may be wrong but as I understand the content of the application level nginx.conf is inserted into a server block of the main nginx.conf. 我可能是错的,但是据我了解,应用程序级别的内容nginx.conf已插入到主nginx.conf的服务器块中。

I've tried the following directive in the nginx.conf but it doesn't work: 我已经在nginx.conf中尝试了以下指令,但是它不起作用:

rewrite http://blog.domain.com http://www.domain.com/blog/ permanent;

Has anyone else managed to do this? 有其他人设法做到这一点吗?

Ok, so I figured this out. 好的,我知道了。 Whilst Ifs are considered evil in nginx this was the best I could do: 虽然在nginx中如果认为“邪恶”是我能做的最好的事情:

if ($http_host = "blog.domain.com") {
    rewrite ^/(.*)$ http://www.domain.com/blog/$1?$args;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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