2016-07-25 94 views
0

Rails中是否有方法將所有子域重新路由到www?例如,如果有人進入https://blah.example.com/campaign/39/public它會路線https://www.example.com/campaign/39/public將所有子域路由到www

等等可以改成像https://google.example.com/campaign/41/public什麼,但它總是路線到www https://www.example.com/campaign/41/public

+0

檢查這個答案http://stackoverflow.com/questions/10594155/rails-redirect-to-current-path-but-different-subdomain – neydroid

+0

在多個url的情況下,不要忘記使用meta canonic在HTML中 –

回答

0

是的,這是可能的重定向任何域鏈接到www。

你需要如下更改conf文件的Apache2和httpd的

<VirtualHost *:80> 
    ServerName blah.example.com 
    Redirect permanent/http://www.example.com/ 
</VirtualHost> 

如果您使用nginx的比使用

server { 
    listen  80; 
    server_name example.com; 
    return  301 http://www.example.com$request_uri; 
} 

server { 
    listen  80; 
    server_name www.example.com; 
    ... 
} 

希望它會幫助你..