I work with Drupal 8.

I've set an url alias for my page to /nice-url. When I acces it via http://mypage.com/nice-url everything works fine.

The problem is, this page is still accessable via http://mypage.com/node/37 - it's bad for SEO and it produces some mess.

Is it possible to remove that http://mypage.com/node/37 page? I mean I want the content of that page to accessable only via http://mypage.com/nice-url.

  • I know you are looking for drupal 8. But for drupal 7 this same question-Answer is available, you can check to get idea to apply for your need. Convert link from node/nid to Pathauto url?
    – CodeNext
    Jul 10 '16 at 1:34
  • it's bad for SEO That's simply not true. Run it through any SEO tool, it will report that canonical meta tags are used properly, as recommended by all major search engines
    – Clive
    Jul 10 '16 at 9:32
  • @Clive agree about SEO - but still... bots generate twice as much traffic for no reason; secondly: redundancy is never good (for example: I could forget about double way of accessing same page and make some twigs that will affect one of it and not the other etc.)
    – PolGraphic
    Jul 11 '16 at 6:23

You don't want to deny access to it but simply redirect to the aliased URL.

That feature is provided by the Redirect module and there's also a core issue to make core do that automatically.

  • The core issue you linked to looks promising. I see that it provides solution for'- path alias redirect, for example from "node/1" to "content/my-node" which is exactly what I need. But - how to use it/enable it?
    – PolGraphic
    Jul 11 '16 at 6:26
  • You don't. It's a work in progress patch. Use the redirect module. As I said, it does the same
    – Berdir
    Jul 11 '16 at 6:38

You could check the URI:

$uri = RequestStack $requestStack->getCurrentRequest()->getRequestUri();

If the URI is 'node/37' you can throw new AccessDeniedHttpException();

But I don't think that this will improve your SEO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.