By default, Drupal core does not redirect the home page node path to the home page. E.g. I configure the home page to be "node/1". I can still visit node/1. This makes sense, because Drupal also includes a canonical link to the to node, thanks to NodeViewBuilder.
I.e. in the html head:
<link rel="canonical" href="/node/1" />
After installing redirect module, visiting my home page E.g. example.com, will give me the canonical link as above. Now if I'm a search engine, I'll try to follow the canonical link... visit example.com/node/1 and I get served a redirect to example.com. Argh. This is essentially a redirect loop. Obviously not all search engines care, but for example in my case, Google Search Appliance with follow canonical links enabled is dying and not indexing any Drupal content.
Ideally I'd like to see an option to disable redirects for content set to be the home page - to avoid this particular problem.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | fix_front_page-2948211-19.patch | 4.06 KB | lily.yan |
| #11 | fix_front_page-2948211-11.patch | 4.17 KB | pratip.ghosh |
| #6 | fix_front_page-2948211-6.patch | 1.29 KB | vj |
| #2 | redirect-ignore_front_page_redirects-2948211-2.patch | 661 bytes | pingers |
Issue fork redirect-2948211
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pingers commentedHere's a terrible patch, which fixes the use case for me ... but doesn't provide the option.
I tried adding the path matcher service to the RedirectChecker, but this caused more problems...
The path matcher isFrontPage() method ran too early in the request, so it caches FALSE (because routeMatch->getRouteName() returns null), when it is in fact the front page path. Grrr.
Hope this helps someone... and maybe one day I'll get around to rolling a better patch. Sorry.
Comment #3
pingers commentedI should probably mention I also went down the road of #1255092: Return "/" instead of the internal path when asked for the URL of the frontpage overriding the url generator service. This caused more problems for me by breaking front page detection.
Comment #4
pifagor commentedthe patch does not go through automatic testing.
Comment #5
pingers commentedI'm not sure the patch is actually something maintainers will want to merge... it's more that I had a project requirement to do it.
If we want it in, I'll happily refactor the tests.
Comment #6
vj commentedFaced this issue with vanilla Drupal installation and redirect module.
Steps to reproduce.
front: /homein system.site.yml & rundrush cimComment #8
berdirThat seems like the opposite of what is talked about there. And might "just" be a cache problem? IMHO, the metadata on the frontpage should *not* point to node/1. With metatag, you can already configure it like that and I think it would make sense to do that by default.
Comment #9
vj commented@Berdir
For me canonical link is not an issue. Its same with and without redirect module.
<link rel="canonical" href="http://drupalvm.test/home" />My issue is related to redirect from domain.com to domain.com/home. Which is happening due to
$this->pathMatcher->isFrontPage()in src/EventSubscriber/RouteNormalizerRequestSubscriber.php returns false on frontpage.Steps to reproduce.
Its more of core bug which fails to detect frontpage with above steps hence redirect module fails for me.
Issue to drupal core : https://www.drupal.org/project/drupal/issues/1503146
Let me know your thoughts, any way to avoid redirect from domain.com to domain.com/home
Comment #10
komlenic commentedComment #11
pratip.ghosh commentedModified patch with dependency injections.
Comment #12
ryan.ryan commentedPatch does apply cleanly and resolves the issue of the homepage redirecting to the canonical URL. I'll report back if there's any undesirable side effects.
Comment #13
komlenic commentedConfirming that patch resolves this issue with no observed issues.
If nothing else it seems this should be moved to "Needs review" but I'm bumping to RTBC for now.
Comment #16
liam morlandCreated merge request with patch #11.
Comment #17
bradjones1Looks like a few easy-ish issues with test constructors.
Comment #18
liam morlandThe problem is that in
RouteNormalizerRequestSubscriberTest::getSubscriber(), a newRouteNormalizerRequestSubscriberobject is created and when that happens, only four parameters are send in to the constructor. The two new parameters,$path_currentand$path_alias_manager, are missing.Comment #19
lily.yan commentedRerolled fix_front_page-2948211-11.patch in comment#11 based on 8.x-1.8
Comment #20
morbus iff#19 works for me.
Comment #21
amateescu commentedNote that there's also a core patch dealing with this problem: #1503146: Aliased paths cannot be set as front page
This will run path alias processing before routing is done (i.e. before
\Drupal\path_alias\EventSubscriber\PathAliasSubscriber::onKernelController()), and will disable core's pre-loading optimization. See #2508217-14: AliasManager should use the current route match for outbound alias pre-loading cache keys for details.Comment #23
weekbeforenextI resolved merge conflicts with the MR.