2017-07-02 118 views
1

这里是我的角度路由器的配置:阿帕奇重定向到的sitemap.xml误差分量

const appRoutes: Routes = [ 
{ path: 'home', component: HomeComponent, 
data: { 
    animation: { 
    value: 'home', 
    } 
} 
}, 
{ path: 'about', component: AboutComponent, 
data: { 
    animation: { 
    value: 'about', 
    } 
} 
}, 
{ path: '', redirectTo: 'home', pathMatch: 'full' }, 
{ path: '**', component: ErrorComponent } 
]; 

每次我尝试导航到www.myapp.com/sitemap.xml它匹配ErrorComponent并重定向到我的404页。

如何配置Apache服务器停止sitemap.xml去index.html?

下面是我的.htaccess文件我重写规则:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.html$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.html [L] 
</IfModule> 
+1

配置您的服务器不** **到index.html的服务时的路径是sitemap.xml的 –

+0

我如何可以针对在.htaccess文件sitemap.xml的? – adamjesmith

+0

我已将.htaccess代码添加到信息 – adamjesmith

回答

0

我想通了。我只需要添加下面的重写规则来重定向到sitemap.xml文件。

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^sitemap\.xml$ sitemap.xml [L] 
    RewriteRule ^index\.html$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.html [L] 
</IfModule>