diff --git a/nextcloud-defaults.inc b/nextcloud-defaults.inc
index 0ed8397..fef3ec6 100644
--- a/nextcloud-defaults.inc
+++ b/nextcloud-defaults.inc
@@ -1,78 +1,8 @@
-# These are based on the .htaccess file shipped by ownCloud, with
-# appropriate adjustments for distribution packaging. Some directives
-# that are irrelevant to the Fedora/EPEL ecosystem are omitted. This
-# file contains directives that should be applied within the /nextcloud
-# filesystem; directives that should be applied site-wide when
-# ownCloud is installed are placed directly in nextcloud.conf.
+# The contents of the default Nextcloud .htaccess file are appended to this
+# file during build. Some directives may be irrelevant to the Fedora/EPEL
+# ecosystem but are NOT omitted.
#
# DO NOT EDIT THIS FILE DIRECTLY. To override any element of the
-# packaged ownCloud configuration, create a new /etc/httpd/conf.d/
-# file which will be read later than 'nextcloud.conf'.
+# packaged Nextcloud configuration, create a new /etc/httpd/conf.d/
+# file which will be read later than this one.
-AllowOverride None
-
-ErrorDocument 403 /nextcloud/core/templates/403.php
-ErrorDocument 404 /nextcloud/core/templates/404.php
-
-
-
-
- SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
- RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
-
-
-
- SetHandler "proxy:unix:/run/php-fpm/nextcloud.sock|fcgi://localhost"
-
-
-
-
- php_value upload_max_filesize 10G
- php_value post_max_size 10G
- php_value memory_limit 512M
- php_value mbstring.func_overload 0
- php_value always_populate_raw_post_data -1
- php_value default_charset 'UTF-8'
- php_value output_buffering off
-
- SetEnv htaccessWorking true
-
-
-
-
- php_value upload_max_filesize 10G
- php_value post_max_size 10G
- php_value memory_limit 512M
- php_value mbstring.func_overload 0
- php_value always_populate_raw_post_data -1
- php_value default_charset 'UTF-8'
- php_value output_buffering off
-
- SetEnv htaccessWorking true
-
-
-
-# The rewrites for legacy caldav and carddav URLs are omitted here
-# because they do not work with Fedora's ownCloud directory layout.
-# See https://github.com/nextcloud/core/issues/243#issuecomment-75426453
-
- RewriteEngine on
- RewriteBase /nextcloud/
- RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
- RewriteRule ^remote/(.*) remote.php [QSA,L]
-
-
-AddDefaultCharset utf-8
-Options -Indexes
-
-
- ModPagespeed Off
-
-
-
-
- Header set Cache-Control "max-age=7200, public"
-
- # https://docs.nextcloud.com/server/25/admin_manual/installation/harden_server.html#enable-http-strict-transport-security
- Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
-
diff --git a/nextcloud-httpd.conf b/nextcloud-httpd.conf
index b009fd2..12c121e 100644
--- a/nextcloud-httpd.conf
+++ b/nextcloud-httpd.conf
@@ -13,15 +13,15 @@ Alias /nextcloud/apps-appstore /var/lib/nextcloud/apps
Alias /nextcloud/assets /var/lib/nextcloud/assets
Alias /nextcloud /usr/share/nextcloud
-# This must be set explicitly in some environments, such as el9
-AddType text/javascript .mjs
-
# Allows compliant CalDAV / CardDAV clients to be configured using only
# the domain name. For more details see # http://tools.ietf.org/html/rfc6764
-Redirect 301 /.well-known/carddav /nextcloud/remote.php/dav
-Redirect 301 /.well-known/caldav /nextcloud/remote.php/dav
-Redirect 301 /.well-known/webdav /nextcloud/remote.php/dav
+# Nextcloud 29 checks specifically for trailing slash in dav 301 redirects
+# https://github.com/nextcloud/server/issues/45033#issuecomment-2079306503
+
+Redirect 301 /.well-known/carddav /nextcloud/remote.php/dav/
+Redirect 301 /.well-known/caldav /nextcloud/remote.php/dav/
+Redirect 301 /.well-known/webdav /nextcloud/remote.php/dav/
Redirect 301 /.well-known/webfinger /nextcloud/index.php/.well-known/webfinger
Redirect 301 /.well-known/nodeinfo /nextcloud/index.php/.well-known/nodeinfo
diff --git a/nextcloud.spec b/nextcloud.spec
index 3e51ca8..d0b1174 100644
--- a/nextcloud.spec
+++ b/nextcloud.spec
@@ -362,6 +362,9 @@ done
# look for our sed placeholder we patched in earlier, then insert our formatted list of keywords
sed -i "s|//sedplaceholder|${formattedlist}|" lib/private/IntegrityCheck/Checker.php
+# Build nextcloud-defaults.inc from upstream .htaccess. We will install it later.
+cat .htaccess >> %{SOURCE105}
+
%check
# Make sure there are no license files left over
: Check for leftover license files