0

I’m deploying a Craft site to a host I’ve not used before (Siteground).

I ran the server check via SSH and everything came back green. Apart from the PHP version which it said 8.0 was the minimum, and it was already set to 8.0.23, (so that was weird).

I moved most of the files up with FTP and then used composer to download the vendor files, set up the database, etc.

Then, following Siteground’s instructions (https://www.siteground.co.uk/kb/hosts-file/) I updated my hosts file to redirect the domain to the server’s IP.

Note: I cannot just point the domain at it because it is a live site, this is a rebuild.

When I test, the home page works great. All the content’s there, comes up fast, no errors, no missing assets. Awesome.

But when I visit any URL other than the home page, a category, or a blog post, or even the privacy policy, I get Siteground’s default 404.

I tried uploading a static HTML file and that did appear correctly. So therefore, there must be some incompatibility between how Craft generates URLs, and Siteground, or the hosts file approach.

Siteground support’s suggestion is to install WordPress. Obviously no. But that does suggest that they expect dynamic URLs to work.

I should add, the site is running fine locally.

If anyone has any advice, or experience with deploying on Siteground I’d be grateful.

1 Answer 1

0

Sounds like you don't have a .htaccess file uploaded in the cms/web directory.

Here's the .htaccess file I use for a couple Craft sites I have hosted on Siteground.

<IfModule mod_headers.c>
    # disables SiteGround's ridiculously overzealous auto-caching
    Header set Cache-Control "private"
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On

    # force www. before the domain
    RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
    RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]

    # force https
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # 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>
1
  • You’re absolutely right. I have no idea how I managed to delete that, it’s not even in my git. Thanks for taking the time, you saved me hours of head scratching.
    – mitrol
    Sep 26, 2022 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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