owncloud-ansible / owncloud

Ansible role for ownCloud 10
https://owncloud-ansible.github.io
Apache License 2.0
6 stars 7 forks source link

Option for removing "index.php" from URL (aka rewritebase) #14

Open PVince81 opened 4 years ago

PVince81 commented 4 years ago

Currently the URL of a provisioned instance always shows "index.php" in the URL. There's an option to make it cleaner.

To make this work, I had to manually do the following on the provisioned instance:

PVince81 commented 4 years ago

Here is how the end of the .htaccess file looks like after running the above occ command:

(...)
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 vagrant.owncloud.demo/core/templates/403.php
ErrorDocument 404 vagrant.owncloud.demo/core/templates/404.php
<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff|ico|jpg|jpeg|json)$
  RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
  RewriteCond %{REQUEST_FILENAME} !/robots.txt
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteCond %{REQUEST_FILENAME} !/updater/
  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
  RewriteCond %{REQUEST_FILENAME} !/ocm-provider/
  RewriteCond %{REQUEST_URI} !^/.well-known/(acme-challenge|pki-validation)/.*
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>

To detect the fact whether this is already correctly set, I guess that we could read the line "RewriteBase /" from the .htaccess file and see if it matches the one from config.php.

In general I guess that for such deployments we probably only support deploying on the server root, in which case we could always use "/" as default there.

PVince81 commented 4 years ago

Official doc here: https://doc.owncloud.com/server/admin_manual/configuration/server/config_sample_php_parameters.html#define-clean-urls-without-index-php

PVince81 commented 4 years ago

Quick attempt at adding this in this PR: https://github.com/owncloud-ansible/owncloud/pull/15