Code integrity .htaccess has not passed the integrity check

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 35.0.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 22.04
  • Web server and version (e.g, Apache 2.4.25):
    • 2.4.69
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • n/a
  • PHP version (e.g, 8.3):
    • 8.3.36
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • Just before and since upgrading from v 34.0.5 to v 35.0.2
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare metal
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • Cloudflare - Yes

Summary of the issue you are facing:

My .htaccess file has failed a “code integrity” check

From my Admin Settings Overview page:

Code integrity

Some files have not passed the integrity check. List of invalid files… Rescan…


And when I hit the “List of invalid files”-option, i get:

Raw output
==========
Array
(
    [core] => Array
        (
            [INVALID_HASH] => Array
                (
                    [.htaccess] => Array
                        (
                            [expected] => a2d827c...
                            [current] => 17477516e...
                        )

                )

        )

)

The problem appeared just before I updated NC from v 34.0.5 to 35.0.2 (my current version) and I thought I had successfully dealt with it via the second solution below:

EDIT: the 3rd attempted solution below produced an acceptable outcome - see also the end of this thread

Solutions attempted:

  1. Tried ernolf’s “nc-integrity-fix”-script, as detailed here:

https://help.nextcloud.com/t/nc-integrity-fix-script-to-resolve-some-files-have-not-passed-the-integrity-check-warnings/194729

Didn’t help:

azed@azed-byte:~$ nc-integrity-fix
This app is affected:

core
The hash of this file in [core] is invalid:

.htaccess

Q: Do you want to replace this invalid file with a file downloaded from github
for your version?
Make your choice: ([y]es or [n]o) [yes]: y
download of '.htaccess' failed. You must check this one yourself


  1. Tried to replace my .htaccess-file for an “uncorrupted” one, as detailed here:

https://help.nextcloud.com/t/code-integrity-check-problems/1895/2

Downloaded the appropriate (v. 34.0.5) nextcloud files from here:

https://nextcloud.com/changelog/#latest34

-- Extracted the .htaccess file

-- Checked permissions matched:

OLD

azed@azed-byte:~$ ls -l /var/www/nextcloud/.htaccess
-rw-r--r-- 1 www-data www-data 7940 Oct 17 17:02 /var/www/nextcloud/.htaccess

NEW

azed@azed-byte:~$ ls -l /home/azed/Downloads/Nextcloud/nextcloud-34.0.5/.htaccess
-rw-r--r-- 1 azed azed 6677 Oct 15 09:17 /home/azed/Downloads/Nextcloud/nextcloud-34.0.5/.htaccess


-- Fixed file ownership:

sudo chown www-data:www-data /home/azed/Downloads/Nextcloud/nextcloud-34.0.5/.htaccess

azed@azed-byte:~$ ls -l /home/azed/Downloads/Nextcloud/nextcloud-34.0.5/.htaccess
-rw-r--r-- 1 www-data www-data 7940 Oct 24 15:44 /home/azed/Downloads/Nextcloud/nextcloud-34.0.5/.htaccess

-- Replaced the old .htaccess-file with the new

azed@azed-byte:~$ sudo mv /home/azed/Downloads/Nextcloud/nextcloud-34.0.5/.htaccess /var/www/nextcloud/.htaccess

-- Reloaded apache2

azed@azed-byte:~$ sudo systemctl reload apache2

When I re-loaded the Administrator Settings Overview page, the code integrity warning had disappeared (hoorah!)

However, after the update to NC v 35.0.2, it re-appeared (boo!)

  1. I also tried this suggested fool-the-system work-around:

https://help.nextcloud.com/t/27-1-1-howto-reset-invalid-hash-on-htaccess-to-eliminate-issue-in-admin-overview/170766

see also here:

https://help.nextcloud.com/t/integrity-check-failed-htaccess-file-invalid/163774/2

Did as suggested:

-- Edited end of /var/www/nextcloud/config/config.php

From:

'mail_smtpport' => '465',
'mail_smtpauth' => 1,
'mail_smtpname' => ``'``withheld',
'mail_smtppassword' => 'withheld',
'theme' => '',
'loglevel' => 2,
'htaccess.RewriteBase' => '/',
'serverid' => '0',
);

To:

'mail_smtpport' => '465',
'mail_smtpauth' => 1,
'mail_smtpname' => 'withheld',
'mail_smtppassword' => 'withheld',
'theme' => '',
'loglevel' => 2,
'htaccess.RewriteBase' => '/',
'serverid' => '0',
'integrity.check.disabled' => true,
);

-- Saved file

-- Re-loaded Admin Settings Overview page - code-integrity error had vanished

-- Removed the line " ‘integrity.check.disabled’ => true, " from /var/www/nextcloud/config/config.php

-- Logged out and in again: code integrity problem was back (sigh)

QUESTIONS:

  1. Why am I getting this error
  2. How do I get rid of it (permanently)?

Log entries

Nextcloud

Here are a couple of entries from the Administrator Settings Overview “Logging”-page from the time of my update to v35.0.2. They don’t appear to me to be very useful:

{"reqId":"wUKyvHlXi3QI9dtIWqOU","level":1,"time":"2026-10-24T14:23:27+00:00","remoteAddr":"192.168.1.237","user":"--","app":"updater","method":"GET","url":"/ocs/v2.php/core/update?requesttoken=YbI9hp8CZHCM4T1rGdgDoxh9N9PqUVUjQO%2FMcgIOb0w%3D%3AEvdL4fBnUgSng2wyd6Fl8ltMTrrTGjpvCt%2BFHHA5IQA%3D","scriptName":"/ocs/v2.php","message":"\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0","version":"34.0.5.1","data":{"app":"updater"},"id":"6ae8a58bc769b"}

{"reqId":"wUKyvHlXi3QI9dtIWqOU","level":1,"time":"2026-10-24T14:23:35+00:00","remoteAddr":"192.168.1.237","user":"--","app":"updater","method":"GET","url":"/ocs/v2.php/core/update?requesttoken=YbI9hp8CZHCM4T1rGdgDoxh9N9PqUVUjQO%2FMcgIOb0w%3D%3AEvdL4fBnUgSng2wyd6Fl8ltMTrrTGjpvCt%2BFHHA5IQA%3D","scriptName":"/ocs/v2.php","message":"\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0","version":"34.0.5.1","data":{"app":"updater"},"id":"6ae8a58bc7696"}

Web Browser

N/A

Web server / Reverse Proxy

Couldn’t see anything relevant /var/log/____

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

Can be provided if you think it would help

Apps

Again, list of apps can be provided if you think it would help

How, precisely, are you updating?

Thanks for your interest, jtr

I use the “update” tool in my Administrator Settings Overview-page. This is what it o/p-ed at my last update (on 24/10)

Initializing
Current version is 34.0.5.
Update to Nextcloud 35.0.2 available. (channel: "stable")
Following file will be downloaded automatically: https://github.com/nextcloud-releases/server/releases/download/v35.0.2/nextcloud-35.0.2.zip
Open changelog ↗
Start update
Check for expected files
Check for write permissions
Create backup
Downloading
Verifying integrity
Extracting
Enable maintenance mode
Replace entry points
Delete old files
Move new files in place
Continue with web based updater
Done

Then, as normal, I continued with the web-based updater, which, on 24/10, o/p this:

Nextcloud will be updated to version 35.0.2
Please make sure that the database, the config folder and the data folder have been backed up before proceeding.
To avoid timeouts with larger installations, you can instead run the following command from your installation directory:
./occ upgrade


Preparing update
Set log level to debug
Turned on maintenance mode
Repair step: Repair MySQL collation
Repair info: All tables already have the correct collation -> nothing to do
Repair step: Copy data from accounts table when migrating from ownCloud
Repair step: Drop account terms table when migrating from ownCloud
Updating database schema
Updated database
Updated "federation" to 2.0.0
Updated "lookup_server_connector" to 2.0.0
Repair step: Update OAuth token expiration times
Updated "oauth2" to 2.0.0
Updated "password_policy" to 7.0.0
Repair step: init metadata
Updated "photos" to 8.0.0
Updated "activity" to 8.0.0
Repair step: Upgrading Circles App
Repair step: Sync groups with their circles
Updated "circles" to 35.0.0
Updated "cloud_federation_api" to 2.0.0
Repair step: Fix component of birthday calendars
Repair info: 2 birthday calendars updated.
Repair step: Regenerating birthday calendars to use new icons and fix old birthday events without year
Repair info: Repair step already executed
Repair step: Fix broken values of calendar objects
[0 / 0]: Fix broken values of calendar objects
Repair step: Registering building of calendar search index as background job
Repair info: Repair step already executed
Repair step: Register building of social profile search index as background job
Repair info: Repair step already executed
Repair step: Disable system address book
Repair info: Skipping repair step system address book has less than the threshold 5000 of contacts no need to disable
Repair step: Registering background jobs to update cache for webcal calendars
Repair info: Added 0 background jobs to update webcal calendars
Repair step: Registering building of calendar reminder index as background job
Repair info: Repair step already executed
Repair step: Register a background job to update rooms and resources
Repair step: Queue jobs to clean up orphan event and contact data
Repair step: Remove activity entries of private events
Repair step: Clean up old calendar subscriptions from deleted users that were not cleaned-up
[0 / 0]: Clean up old calendar subscriptions from deleted users that were not cleaned-up

Again as normal, before the update, I made a backup:

  1. Turned on “maintenance mode”:

sudo -E -u www-data php /var/www/nextcloud/occ maintenance:mode --on

  1. Moved to the parent folder of my nextcloud install

cd /var/www

  1. Backed-up the content of /var/www/nextcloud

rsync -Aavx nextcloud/ /mnt/Goods/NextcloudBackups/NC-NCFolderBackup_date +"%Y%m%d"/

  1. Backed-up the database
cd

mariadb-dump --single-transaction --default-character-set=utf8mb4 -h localhost -u azed -p nextcloud > /mnt/Goods/NextcloudBackups/NC-sqlbkp_date +"%Y%m%d".bak


  1. Turned-off “maintenance mode”
sudo -E -u www-data php /var/www/nextcloud/occ maintenance:mode --off

I wonder: could I substitute the .htaccess-file from one of my pre-24/10 backups?

I don’t really understand why my .htaccess-file has ended-up with the wrong hash-code (whatever)

In fact ('scuse my ignorance), I don’t really know what my .htaccess file does

I understand that it is not exactly unusual for NC to complain and get picky about .htaccess: how do users normally solve this problem?

Thanks for any help you can offer

By the way, I edited my original post to make it less of a mess

***************************************************************************

3 Days later…

Revisited the 3rd of my attempted solutions in my first post. Today, I did exactly this:

  • Logged into my NC instance and opened the Admin Settings overview-page. “code integrity”-error still present
  • Opened /var/www/nextcloud/config/config.php in nano and added “‘integrity.check.disabled’ => true,” (w/o outer quotes) to the end of the file
  • Saved changes with Ctrl+O, then [ENTER]
  • Returned to the Admin Settings Overview-page and hit “Rescan” on the .htaccess error-message. The error-message disappeared
  • Returned to nano (still open) and removed added line. Resaved
  • Exited nano with Ctrl+X

May have to repeat this after every update

The /home/azed/Downloads/Nextcloud/nextcloud-34.0.5/.htaccess was initially:

6677 Oct 15 09:17

Then when you reran ls -l on it after the chown it changed to the following:

7940 Oct 24 15:44

That’s unexpected.