我有一个 AngularJS 1.0.7 网络应用程序。
在我的 app.js 中:
$routeProvider.when('/:language/alquiler-barcos-:departure', {templateUrl: 'partials/boat-rental.html', controller: 'Controller1Ctrl'});
$routeProvider.when('/:language/boat-rental-:departure', {templateUrl: 'partials/boat-rental.html', controller: 'Controller1Ctrl'});
这将使此正确的 URL 如:http://domain/es/alquiler-barcos-mallorca或 http://domain/en/boat-rental-majorca .这是对的。
但是,它也会让http://domain/es/boat-rental-mallorca或 http://domain/en/alquiler-barcos-majorca这是错误的(或者应该是,因为它在 URL 中混合了多种语言)。
我想避免这种情况,因为我认为从 SEO 的 Angular 来看这不太好。首先,我想澄清在这种情况下,从 SEO 的 Angular 来看最佳做法是什么:
重定向http://domain/en/alquiler-barcos-majorca至 http://domain/en/boat-rental-majorca并展示结果
控制 URL 并重定向到 301 错误页面。
控制URL并重定向到首页。
在那之后,有没有办法在app.js中以AngularJS的方式控制这些组合?或者应该只是解析 Controller 中的 url 并“手动”控制它。
最佳答案
- To redirect http://domain/en/alquiler-barcos-majorca to http://domain/en/boat-rental-majorca and show the results
这是最好的 SEO 选项,使用 301 重定向。
- To control the URL and redirect to a 301 error page.
这不是一个很好的选择,因为它会带来糟糕的用户体验。如果您实现它,您应该返回 404 或 410。
- To control the URL and redirect to home page.
这是软 404,它比第二个选项好,但不如第一个选项好。
关于AngularJS,混合语言和 SEO 的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30218975/