Who manages the htaccess file?

Hi :wave:

I set up my Kirby website a few years ago. I am not very familiar with web development and used the starterkit. Below is the Composer file that is currently in use.

composer.json
{
    "name": "getkirby/starterkit",
    "description": "Kirby Starterkit",
    "type": "project",
    "keywords": ["kirby", "cms", "starterkit"],
    "homepage": "https://getkirby.com",
    "authors": [
        {
            "name": "Bastian Allgeier",
            "email": "bastian@getkirby.com",
            "homepage": "https://getkirby.com"
        }
    ],
    "support": {
        "email": "support@getkirby.com",
        "issues": "https://github.com/getkirby/starterkit/issues",
        "forum": "https://forum.getkirby.com",
        "source": "https://github.com/getkirby/starterkit"
    },
    "require": {
        "php": ">=7.1.0",
        "getkirby/cms": "^4.0",
        "sylvainjule/bouncer": "^1.0"
    },
    "config": {
        "optimize-autoloader": true,
        "allow-plugins": {
            "getkirby/composer-installer": true
        }
    }
}

Now I would like to migrate the website from Nginx to Apache. For this reason, I need a .htaccess file in the webroot so that the URLs are resolved correctly and certain URLs (e.g. access to content) are blocked. After running composer install, however, no such .htaccess file is created. For this reason I used the .htaccess file (created manually) from getkirby/starterkit, everything works fine.

Now to my question: Is it correct that I have to create and maintain the .htaccess file manually (Check after each update whether it is still up to date) or should it have been created by Composer?

The documentation says:

Make sure that the .htaccess file that ships with Kirby is present in your Kirby folder.

Best,
Markus

No, composer doesn’t create a .htaccess file. In fact, the .htaccess file in the Starterkit is just there to provide a best-practice example.

In cases where you manage the server yourself, you would not use the .htaccess file but move the directives contained in there to your server config file.

Also, the .htaccess file is only relevant for Apache web servers. For all other web server, including Nginx, it is of no use, and you would have to create similar rules in your nginx.conf file.

See also Running Kirby on a Nginx web server | Kirby CMS

1 Like

I’m aware that I have to manage the web server configuration for Nginx myself (that’s what I’m currently doing). Your answer also answered my question about .htaccess file, thank you!