提问人:Franco Neil Glovasa 提问时间:11/14/2023 更新时间:11/14/2023 访问量:11
如何在 angularjs SPA 上获得 301 响应 - dotnet
How to have 301 response on angularjs SPA - dotnet
问:
我在网络选项卡上看到 301 响应,但在去向或任何 SEO 重定向工具上,我得到了 200 响应。知道如何欺骗 SEO 工具以获得 301 重定向响应吗?
控制器
[HttpGet]
[Route("Redirector")]
public HttpResponseMessage Redirector(string targetUrl)
{
var httpResponse = Request.CreateResponse(HttpStatusCode.MovedPermanently);
httpResponse.Headers.Add("X-Redirect-Status", "301");
httpResponse.Content = new StringContent(targetUrl);
return httpResponse;
}
JS系列
this.redirector = function (newUrl) {
return $http.get("/api/redirect/Redirector?targetUrl=" + newUrl);
};
$ctrl.redirector = function (newUrl) {
redirectService.redirector(newUrl)
.then(function (response) {
var newLocation = response.data;
$location.path(newLocation);
})
.catch(function (error) {
var newLocation = error.data;
$location.path(newLocation);
});
};
答: 暂无答案
评论
X-Redirect-Status