Skip to content

Conversation

@lpcvoid
Copy link

@lpcvoid lpcvoid commented Dec 22, 2025

Currently, the updateHtaccess() function can't deal with a missing .htaccess file, it assumes at least an empty .htaccess file.

In some cases, the file may be missing though, and this PR adds functionality for creating it when this edgecase occurs.

Before this PR, executing occ maintenance:update:htaccess can fail without the error message being explicit about this edgecase.

  • Resolves: # Many issues that complain about occ maintenance:update:htaccess not working.

Summary

occ maintenance:update:htaccess can now also create .htaccess files, instead of relying on them being present.

TODO

  • Nothing I can think of

Checklist

Currently, the updateHtaccess() function can't deal with a missing
.htaccess file, it assumes at least an empty .htaccess file.

In some cases, the file may be missing though, and this commit
adds functionality for creating it when this edgecase occurs.

Signed-off-by: Marc <[email protected]>
@lpcvoid lpcvoid requested a review from a team as a code owner December 22, 2025 11:12
@lpcvoid lpcvoid requested review from ArtificialOwl, come-nc, nfebe and provokateurin and removed request for a team December 22, 2025 11:12
This adds a hint to the error message that file creation may also
have failed.

Signed-off-by: Marc <[email protected]>
Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this. The file needs to exist beforehand otherwise it might misses the important default config: https://github.com/nextcloud/server/blob/master/.htaccess

@lpcvoid
Copy link
Author

lpcvoid commented Jan 5, 2026

I had a situation where I copied over a directory using cp * ../ -R. This doesn't copy dotfiles, which I forgot because I am stupid. Then I was wondering why this command doesn't work, and the error message was not helpful at all. It took me a bit to figure it out.

I am not aware of many of the potential side issues this may cause, but when I tested this locally, it fixed my problem. I also think it's better to have a .htaccess file with some content vs one without any.

It's up to you to do with this what you think is best, of course.

@szaimen
Copy link
Contributor

szaimen commented Jan 5, 2026

I had a situation where I copied over a directory using cp * ../ -R. This doesn't copy dotfiles, which I forgot because I am stupid. Then I was wondering why this command doesn't work, and the error message was not helpful at all. It took me a bit to figure it out.

I am not aware of many of the potential side issues this may cause, but when I tested this locally, it fixed my problem. I also think it's better to have a .htaccess file with some content vs one without any.

It's up to you to do with this what you think is best, of course.

In my opinion the command should fail if the file does not exist but maybe we could improve the error message?

@lpcvoid
Copy link
Author

lpcvoid commented Jan 5, 2026

That's probably a good idea in any case, yeah :) Shall I remove the commit which adds the creation, and keep the single commit which changes the error message?

@szaimen
Copy link
Contributor

szaimen commented Jan 5, 2026

That's probably a good idea in any case, yeah :) Shall I remove the commit which adds the creation, and keep the single commit which changes the error message?

Sounds good to me, yes :)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants