Skip to content

Conversation

@joshtrichards
Copy link
Member

@joshtrichards joshtrichards commented Aug 20, 2025

Summary

Despite the size this changes should be a no-op in terms of functionality. Just trying to ease future maintenance burden:

  • Identified opportunities for future streamlining (dead/unnecessary code) and implementation consistency
  • Made it clearer what things are there for + where they fit in with our various endpoints

Added:

  • New comments/explanations within the rewrite rules section
  • Separated distinct RewriteRules into dedicated sections for ease of maintenance

Changed:

  • Distinct indentation for greater visibility of section hierarchy
  • Moved the global HTTP_AUTHORIZATION workaround rule to the top (rather than being second)
    • This was the only implementation change, but should be a no-op for all practical purposes

Possible follow-ups:

  • Some potential follow-up items (most are marked with XXX in the comments) were discovered while doing this refactor
  • The rules used for htaccess.rewritebase should also be audited and possibly restructured in a similar manner:
    • if ($rewriteBase !== '') {
      $content .= "\n<IfModule mod_rewrite.c>";
      $content .= "\n Options -MultiViews";
      $content .= "\n RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]";
      $content .= "\n RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !\\.(css|js|mjs|svg|gif|ico|jpg|jpeg|png|webp|html|otf|ttf|woff2?|map|webm|mp4|mp3|ogg|wav|flac|wasm|tflite)$";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !/core/ajax/update\\.php";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !/core/img/(favicon\\.ico|manifest\\.json)$";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !/(cron|public|remote|status)\\.php";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !/ocs/v(1|2)\\.php";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !/robots\\.txt";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !/(ocs-provider|updater)/";
      $content .= "\n RewriteCond %{REQUEST_URI} !^/\\.well-known/(acme-challenge|pki-validation)/.*";
      $content .= "\n RewriteCond %{REQUEST_FILENAME} !/richdocumentscode(_arm64)?/proxy.php$";
      $content .= "\n RewriteRule . index.php [PT,E=PATH_INFO:$1]";
      $content .= "\n RewriteBase " . $rewriteBase;
      $content .= "\n <IfModule mod_env.c>";
      $content .= "\n SetEnv front_controller_active true";
      $content .= "\n <IfModule mod_dir.c>";
      $content .= "\n DirectorySlash off";
      $content .= "\n </IfModule>";
      $content .= "\n </IfModule>";
      $content .= "\n</IfModule>";
  • Any future implementation changes may need to be coordinated with:
    • Doc changes for the suggested Nginx configuration
    • AIO? (maybe)
    • Community micro-services Docker image (maybe)

TODO

  • ...

Checklist

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards changed the title chore: refactor .htaccess chore: refactor .htaccess to ease maintenance/future cleanup Aug 20, 2025
@joshtrichards joshtrichards added 3. to review Waiting for reviews feature: dav feature: authentication ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Aug 20, 2025
@joshtrichards joshtrichards changed the title chore: refactor .htaccess to ease maintenance/future cleanup chore: refactor .htaccess to ease maintenance/future cleanup Aug 20, 2025
@joshtrichards joshtrichards marked this pull request as ready for review August 20, 2025 18:33
@joshtrichards joshtrichards requested a review from a team as a code owner August 20, 2025 18:33
@joshtrichards joshtrichards requested review from come-nc and salmart-dev and removed request for a team August 20, 2025 18:33
@joshtrichards joshtrichards added this to the Nextcloud 32 milestone Aug 20, 2025
Signed-off-by: Josh <josh.t.richards@gmail.com>
<IfModule mod_env.c>
SetEnv htaccessWorking true
</IfModule>
php_value mbstring.func_overload 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

mbstring.func_overload was removed with php8

Copy link
Member Author

Choose a reason for hiding this comment

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

#53578 ;-)

Copy link
Contributor

Choose a reason for hiding this comment

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

merged, please rebase and fix conflicts here

@szaimen
Copy link
Contributor

szaimen commented Aug 21, 2025

  • AIO? (maybe)

AIO uses Apache under the hood so no manual changes should not be needed. See https://github.com/nextcloud/all-in-one/blob/main/Containers/apache/nextcloud.conf#L31

This was referenced Aug 22, 2025
This was referenced Sep 2, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: authentication feature: dav ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants