Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Craft randomly throws a 404 when viewing an entry in multi site setup #4320

Open
robbelaloo opened this issue May 28, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@robbelaloo
Copy link

commented May 28, 2019

Description

I'm having trouble with my multi site setup. The issue can be seen here

As you can see, the page sometimes gives a 404 and sometimes shows the entry. Most of the times it's the 404, but sometimes the correct page. When I enable devMode on the staging it gives me "Template not found: safety-drone".
On the default site, everything works as expected.

The general cfg for staging:

'staging' => [
        // Craft defined config settings
        'allowUpdates' => true,
        'backupOnUpdate' => false,
        'devMode' => false,
        'enableTemplateCaching' => true,
        'isSystemLive' => true,
        // Aliases parsed in sites’ settings, volumes’ settings, and Local volumes’ settings
        'aliases' => [
        ],
        // Custom site-specific config settings
        'custom' => [
        ],
        'siteUrl' => [
          'default' => 'https://staging.ncentric.com/',
          'citymeshEn' => 'https://staging.ncentric.com/en/',
          'citymeshFr' => 'https://staging.ncentric.com/fr/'
        ]
    ],

My .htaccess in /web:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Static file versioning
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1.$3 [L]

    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>

Does anyone have an idea what could be the cause of this? If you need more information, please ask and I'll provide.

Thanks in advance

Additional info

  • Craft version: Craft Pro 3.1.28
  • PHP version: 7.1.29
  • Database driver & version: MySQL 5.7.22
  • Plugins & versions:

Screenshot 2019-05-28 at 17 12 55

@brandonkelly

This comment has been minimized.

Copy link
Member

commented May 28, 2019

Guessing that you are running Craft from 2+ load-balanced servers, and the page is reliably working on one/some server(s) and reliably 404ing on another server(s).

If you are able to force traffic to specific servers you can determine which one(s) it works on vs. which one(s) it 404s, and then look into why it’s not working on the 404 server(s).

The 404 message you are getting (“Template not found: safety-drone”) means that Craft couldn’t find a live element for the URI safety-drone (step 3 in the Routing docs), and fell back on assuming it was a template path that had been requested (step 4). If the entry has a Post Date or Expiry Date set, it could be that one of the servers’ clocks are off, so it thinks the entry is either still pending or already expired, but that’s just a shot in the dark.

@robbelaloo

This comment has been minimized.

Copy link
Author

commented May 29, 2019

Well, I have 3 sites at the moment each with their localisation:

  • nl (default)
  • en
  • fr

The link that I provided goes to the English site and gives the random 404 or entry page. This does not happen for the default site. It always works there (https://staging.ncentric.com/safety-drone). If the issue would be with the load-balancing, wouldn't the same issue happen for the default site too then?

Anyways, I'm going to make a new Laravel Homestead setup on my local machine to test everything out. Was using Laravel Valet until now and it has proven very difficult to get a multi site up and running on that one. Just to make sure that the problem is not with the Craft 3 cms.
I'll report back when that's done.

@brandonkelly

This comment has been minimized.

Copy link
Member

commented May 30, 2019

If the issue would be with the load-balancing, wouldn't the same issue happen for the default site too then?

It depends on what the culprit ends up being. 99% chance that Craft is doing what it’s supposed to though, and the issue is environmental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.