RewriteRule from apache config doensnt function, .htaccess do

Discussion in 'ISPConfig 3 Priority Support' started by cmks, Mar 15, 2026 at 2:44 PM.

  1. cmks

    cmks Member HowtoForge Supporter

    Dear team,
    we habe a nextcloud installation at the website under directory
    /nc
    Placeing a .htaccess file under
    /var/www/clients/client99/web999/web/.htaccess
    Code:
    RewriteEngine On
    RewriteRule ^\.well-known/carddav /nc/remote.php/dav [R=301,L]
    RewriteRule ^\.well-known/caldav /nc/remote.php/dav [R=301,L]
    RewriteRule ^\.well-known/webfinger /nc/index.php/.well-known/webfinger [R=301,L]
    RewriteRule ^\.well-known/nodeinfo /nc/index.php/.well-known/nodeinfo [R=301,L]
    
    does the job.

    Inserting a snippet in Website -> Options ->Apache Directives
    Code:
    <IfModule mod_headers.c>
          Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
    </IfModule>
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteRule ^\.well-known/carddav /nc/remote.php/dav [R=301,L]
      RewriteRule ^\.well-known/caldav /nc/remote.php/dav [R=301,L]
      RewriteRule ^\.well-known/webfinger /nc/index.php/.well-known/webfinger [R=301,L]
      RewriteRule ^\.well-known/nodeinfo /nc/index.php/.well-known/nodeinfo [R=301,L]
    </IfModule>
    or
    Code:
    <IfModule mod_headers.c>
          Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
    </IfModule>
    <IfModule mod_rewrite.c>
     <Directory "{DOCROOT}">
      RewriteEngine on
      RewriteRule ^\.well-known/carddav /nc/remote.php/dav [R=301,L]
      RewriteRule ^\.well-known/caldav /nc/remote.php/dav [R=301,L]
      RewriteRule ^\.well-known/webfinger /nc/index.php/.well-known/webfinger [R=301,L]
      RewriteRule ^\.well-known/nodeinfo /nc/index.php/.well-known/nodeinfo [R=301,L]
     </Directory>
    </IfModule>
    does not work.
    "Apache AllowOverride" is set to "All"

    We prefer a solution using the web GUI of ISPConfig. Why does that way not do the job?
    Thank you for any help
    cmks
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the generated vhost file if your custom config is included in the vhost, or if it was rejected by Apache and saved with .err file extension in the Apache sites-available folder.
     
  3. cmks

    cmks Member HowtoForge Supporter

    It is appended to the .vhost config at the end of the VirtualHost *:443 section but not to the *:80 part.
    apache restarts w/o any error.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPConfig always adds it to both vhost sections. Please double-check it, you might have missed that it's set in both. If it is not added in both sections, then you probably use a custom vhost template and configured it to not add it to one section.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Also this:

    Code:
    <IfModule mod_headers.c>
          Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
    </IfModule>
    <IfModule mod_rewrite.c>
     <Directory "{DOCROOT}">
      RewriteEngine on
      RewriteRule ^\.well-known/carddav /nc/remote.php/dav [R=301,L]
      RewriteRule ^\.well-known/caldav /nc/remote.php/dav [R=301,L]
      RewriteRule ^\.well-known/webfinger /nc/index.php/.well-known/webfinger [R=301,L]
      RewriteRule ^\.well-known/nodeinfo /nc/index.php/.well-known/nodeinfo [R=301,L]
     </Directory>
    </IfModule>
    must probably use {DOCROOT_CLIENT} and not {DOCROOT}.
     

Share This Page