Change Document root to nextcloud directory

My nextcloud is installed in document root /var/www/nextcloud

I don’t want nextcloud to load its login screen at www.example.com, but instead at www.example.com/nextcloud

In other words I would like my own index.html to load at www.example.com and not nextclouds index.php in the nextcloud directory.
I had this working on a previous install but not sure what to change. I’m using nginx and php8.1

Maybe you find this resources useful:

https://docs.nextcloud.com/server/stable/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-the-nginx-webroot

https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html?highlight=webroot

No nothing helped, I think the problem is in /etc/nginx/conf.d/nextcloud.conf
There is allot of rewrite stuff that I don’t understand in that config file. like this for instance:

    location / {
       rewrite ^ /index.php;
    }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
       deny all;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
       deny all;
     }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {