<p>Sounds like you don't have a <code>.htaccess</code> file uploaded in the <code>cms/web</code> directory.</p>
<p>Here's the <code>.htaccess</code> file I use for a couple Craft sites I have hosted on Siteground.</p>
<pre><code>&lt;IfModule mod_headers.c&gt;
    # disables SiteGround's ridiculously overzealous auto-caching
    Header set Cache-Control &quot;private&quot;
&lt;/IfModule&gt;

&lt;IfModule mod_rewrite.c&gt;
    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]
&lt;/IfModule&gt;
</code></pre>

CC BY-SA 4.0
2022-09-26T11:35:28.877Z
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
CC BY-SA 4.0
2022-09-24T21:11:13.257Z
2022-09-24T21:11:13.257Z
stevecomrie
<p>I’m deploying a Craft site to a host I’ve not used before (Siteground).</p>
<p>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).</p>
<p>I moved most of the files up with FTP and then used composer to download the vendor files, set up the database, etc.</p>
<p>Then, following Siteground’s instructions (<a href="https://www.siteground.co.uk/kb/hosts-file/" rel="nofollow noreferrer">https://www.siteground.co.uk/kb/hosts-file/</a>) I updated my hosts file to redirect the domain to the server’s IP.</p>
<p>Note: I cannot just point the domain at it because it is a live site, this is a rebuild.</p>
<p>When I test, the home page works great. All the content’s there, comes up fast, no errors, no missing assets. Awesome.</p>
<p>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.</p>
<p>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.</p>
<p>Siteground support’s suggestion is to install WordPress. Obviously no. But that does suggest that they expect dynamic URLs to work.</p>
<p>I should add, the site is running fine locally.</p>
<p>If anyone has any advice, or experience with deploying on Siteground I’d be grateful.</p>

<deployment>
Siteground hosts file issue with Craft
# Siteground hosts file issue with Craft

(Asked by: username_0 on 2022-09-23)

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.

**Tags:** deployment


---

## 1 answers

### Answer by username_1 on 2022-09-24. Score: 0 | Accepted answer

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.

    # disables SiteGround's ridiculously overzealous auto-caching
    Header set Cache-Control "private"



    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]

> **Comments:**
> **username_0**: 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.  

---

