2015-04-24 19 views
1

我有多个域我指向同一台机器(一些子域),主站点使用AngularJS呈现。我有一个新的域名www.newsite.com要添加,但我希望这个新的域名指向主网站上的一个页面,即http://example.co/#/newsite,有没有一个聪明的方法来做到这一点与Apache重写规则?我也没有html5模式工作,所以修复,以便我可以摆脱网站网址中的#可能会很好。在同一台机器上使用多个域的Angular网站的Apache重写规则

我目前的设置是像这样:

主要站点:

  • 位于位于/ var/www/html等/网站,网址http://example.co

    000-default.conf文件:

    <VirtualHost *:80> 
    
        ServerName example.co 
        ServerAlias www.example.co 
        ServerAdmin [email protected] 
        DocumentRoot /var/www/html/site 
    
    </VirtualHost> 
    

博客网站:

  • 位于位于/ var/www/html等/网站/博客,网址:http://blog.example.co

    blog.conf文件:

    <VirtualHost *:80> 
        ServerName blog.example.co 
    
        DocumentRoot /var/www/html/site/blog 
    
        <Directory /> 
          Options FollowSymLinks 
          AllowOverride None 
        </Directory> 
    
        <Directory /var/www/html/site/blog/> 
          Options FollowSymLinks MultiViews 
          AllowOverride All 
          Order allow,deny 
          allow from all 
        </Directory> 
    
    </VirtualHost> 
    

.ORG网站:

  • 相同的位置在/ var/www/html等/网站,网址:http://example.org

    org.conf文件:

    <VirtualHost *:80> 
        ServerName www.example.org 
        ServerAlias example.org 
    
        DocumentRoot /var/www/html/site 
    
        <Directory /var/www/html/site/> 
          Options FollowSymLinks MultiViews 
          AllowOverride All 
          Order allow,deny 
          allow from all 
        </Directory> 
    
    </VirtualHost> 
    

所以我想我需要做的是创造另一个.conf文件,如下所示:

new site site:

  • 也位于位于/ var/www/html等/网站,但该网站地址为http://example.co/#/newsite

    newsite.conf文件:

    <VirtualHost *:80> 
        ServerName www.newexample.com 
        ServerAlias newexample.com 
    
        DocumentRoot /var/www/html/site 
    
        <Directory /var/www/html/site/> 
          Options FollowSymLinks MultiViews 
          AllowOverride All 
          Order allow,deny 
          allow from all 
        </Directory> 
    
    </VirtualHost> 
    

,然后作出.htaccess文件主(?)网站,它允许来自newexample.com的任何流量被定向到http://example.co/#/newsite

+0

不知道为什么你不只是让你的角度路由器设置使用'否则路径的最后部分之前只检查location.host({redirecTo:...}) '。在设置 – charlietfl

+0

之前,请检查'location.host'!好的电话,想要提交答案? – redband

回答

1

您可以在角路由器上为路径的最后部分进行配置。

设置应用程序的otherwise重定向默认