【发布时间】:2020-04-13 18:02:32
【问题描述】:
我有一个 Angular 应用程序和一些 dotnet Web API。出于 SEO 目的,我需要通过 Url 从我的 Angular 应用程序中提供站点地图,例如https://myapp.com/sitemap
站点地图本身由其中一个 API(例如 https://api1.com/sitemap)生成和提供服务,并返回完整的站点地图。
在 google 网站管理员工具中,您只能添加来自当前域的站点地图链接,在我的例子中是 https://myapp.com。
目前,我正在纠结如何将https://myapp.com/sitemap 之类的路由添加到我的 routes.ts 中,以便仅从 API 提供站点地图,而没有 Angular 应用程序的其他内容。 p>
编辑:我的 Angular 应用的网络服务器的 .htcaccess
# This is for other websites in webserer dir which uses php
AddType application/x-httpd-php71 .php
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !=admin.kombas.de
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# Sitemap: Need rewrite for https://kombas.de/sitemap
RewriteRule "^/sitemap" "https://kombasapicontent.azurewebsites.net/api/data/sitemap" [L,P]
#RewriteRule ^/sitemap https://kombasapicontent.azurewebsites.net/api/data/sitemap [L,P] # No quotes make no difference
#RewriteRule "sitemap" "https://kombasapicontent.azurewebsites.net/api/data/sitemap" [L,P] # Only visible reaction => The requested URL was not found on this server.
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
不知何故,我没有任何重写工作。
【问题讨论】:
标签: angular asp.net-core-webapi sitemap