]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Support using Shaarli without URL rewriting
authorArthurHoaro <arthur@hoa.ro>
Fri, 16 Oct 2020 10:47:11 +0000 (12:47 +0200)
committerArthurHoaro <arthur@hoa.ro>
Fri, 16 Oct 2020 10:47:11 +0000 (12:47 +0200)
   - Shaarli can be fully used by prefixing any URL with /index.php/
   - {$base_path} used in templates already works with this configuration
   - Assets path (outside of theme's assets) must be prefixed with {$root_url}/
   - Documentation section in « Server configuration »

Fixes #1590

application/render/PageBuilder.php
doc/md/Server-configuration.md
plugins/archiveorg/archiveorg.php
plugins/qrcode/qrcode.php
tpl/default/daily.html
tpl/default/includes.html
tpl/default/linklist.html
tpl/default/page.footer.html
tpl/default/picwall.html
tpl/default/pluginsadmin.html

index 41b357dd72caccc9fe0525b29d3dbc2a31876db2..2d6d2dbed983d4fe2d8f0d2db00003f118e55141 100644 (file)
@@ -174,10 +174,12 @@ class PageBuilder
             }
         }
 
+        $rootPath = preg_replace('#/index\.php$#', '', $basePath);
         $this->assign('base_path', $basePath);
+        $this->assign('root_path', $rootPath);
         $this->assign(
             'asset_path',
-            $basePath . '/' .
+            $rootPath . '/' .
             rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' .
             $this->conf->get('resource.theme', 'default')
         );
index 14070c8abc7dfc443c630718f0fb024a734b6a13..73302bc61bbcf534b81883289f1a8d9f121310c3 100644 (file)
@@ -362,7 +362,23 @@ sudo systemctl reload nginx
 
 If Shaarli is hosted on a server behind a [reverse proxy](https://en.wikipedia.org/wiki/Reverse_proxy) (i.e. there is a proxy server between clients and the web server hosting Shaarli), configure it accordingly. See [Reverse proxy](Reverse-proxy.md) configuration.
 
+## Using Shaarli without URL rewriting
 
+By default, Shaarli uses Slim framework's URL, which requires
+URL rewriting.
+
+If you can't use URL rewriting for any reason (not supported by
+your web server, shared hosting, etc.), you *can* use Shaarli
+without URL rewriting.
+
+You just need to prefix your URL by `/index.php/`.
+Example: instead of accessing `https://shaarli.mydomain.org/`,
+use `https://shaarli.mydomain.org/index.php/`.
+
+**Recommended:**
+  * after installation, in the configuration page, set your header link to `/index.php/`.
+  * in you `config.json.php` set `general.root_url` to
+    `https://shaarli.mydomain.org/index.php/`.
 
 ## Allow import of large browser bookmarks export
 
index 922b5966fe3340b203b8c98cc6f970555e4b43a5..a7b595e163424fa3ce3e1b2a181e3bdc4f9d1575 100644 (file)
@@ -17,7 +17,8 @@ use Shaarli\Plugin\PluginManager;
 function hook_archiveorg_render_linklist($data)
 {
     $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
-    $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
+    $rootPath = preg_replace('#/index\.php$#', '', $data['_BASE_PATH_'] ?? '');
+    $path = $rootPath . '/' . PluginManager::$PLUGINS_PATH;
 
     foreach ($data['links'] as &$value) {
         $isNote = startsWith($value['real_url'], '/shaare/');
index 95499e39f5a9618cfec8bcb4f0a28ed8922537ca..4571285986dce3d41f14687b3efa949aab338f36 100644 (file)
@@ -19,7 +19,8 @@ function hook_qrcode_render_linklist($data)
 {
     $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html');
 
-    $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
+    $rootPath = preg_replace('#/index\.php$#', '', $data['_BASE_PATH_'] ?? '');
+    $path = $rootPath . '/' . PluginManager::$PLUGINS_PATH;
     foreach ($data['links'] as &$value) {
         $qrcode = sprintf(
             $qrcode_html,
index 3ab8053f753280d348a00b31da3cd5c00e4d2f44..3749bffb620a317c276c4b63a2e9aa42b031a67d 100644 (file)
@@ -76,7 +76,7 @@
                   </div>
                   {if="$thumbnails_enabled && !empty($link.thumbnail)"}
                     <div class="daily-entry-thumbnail">
-                      <img data-src="{$link.thumbnail}#" class="b-lazy"
+                      <img data-src="{$root_path}/{$link.thumbnail}#" class="b-lazy"
                            src=""
                            alt="thumbnail" width="{$thumbnails_width}" height="{$thumbnails_height}" />
                     </div>
index 09768ac47905908bc5cbc274e230a407541bd946..3e3fb6640a52b366af7c3ad96b23484c5000f9b4 100644 (file)
   <link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" />
 {/if}
 {loop="$plugins_includes.css_files"}
-  <link type="text/css" rel="stylesheet" href="{$base_path}/{$value}?v={$version_hash}#"/>
+  <link type="text/css" rel="stylesheet" href="{$root_path}/{$value}?v={$version_hash}#"/>
 {/loop}
 {if="is_file('data/user.css')"}
-  <link type="text/css" rel="stylesheet" href="{$base_path}/data/user.css#" />
+  <link type="text/css" rel="stylesheet" href="{$root_path}/data/user.css#" />
 {/if}
 <link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#"
       title="Shaarli search - {$shaarlititle}" />
index b08773d8576162861561f359710d89346a69d509..e1fb54dd463d2626c99f83f5e0f2f061c7b6fc51 100644 (file)
                 <div class="thumbnail">
                   {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore}
                   <a href="{$value.real_url}" aria-hidden="true" tabindex="-1">
-                  <img data-src="{$base_path}/{$value.thumbnail}#" class="b-lazy"
+                  <img data-src="{$root_path}/{$value.thumbnail}#" class="b-lazy"
                     src=""
                     alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
                   </a>
index 51bdb2f0b0eb0569f0b42e8d2255ccafb3a334d8..ea84aab97159a1362dda47b493e3ee8cb7670fc5 100644 (file)
@@ -10,7 +10,7 @@
     {/if}
     &middot;
     {'The personal, minimalist, super-fast, database free, bookmarking service'|t} {'by the Shaarli community'|t} &middot;
-    <a href="{$base_path}/doc/html/index.html" rel="nofollow">{'Documentation'|t}</a>
+    <a href="{$root_path}/doc/html/index.html" rel="nofollow">{'Documentation'|t}</a>
       {loop="$plugins_footer.text"}
           {$value}
       {/loop}
@@ -25,7 +25,7 @@
 {/loop}
 
 {loop="$plugins_footer.js_files"}
-       <script src="{$base_path}/{$value}#"></script>
+       <script src="{$root_path}/{$value}#"></script>
 {/loop}
 
 <div id="js-translations" class="hidden">
index b7a56c89b17fb56540e1127acff994122286d035..ac613b35d56080bf0c4a0f303324871082d2e9d4 100644 (file)
@@ -31,7 +31,7 @@
       {loop="$linksToDisplay"}
         <div class="picwall-pictureframe" role="listitem">
           {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore}
-          <img data-src="{$value.thumbnail}#" class="b-lazy"
+          <img data-src="{$root_path}/{$value.thumbnail}#" class="b-lazy"
                src=""
                alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
           <a href="{$value.real_url}"><span class="info">{$value.title}</span></a>
index 05d13556231418de5528e8053a7413f14f239d9d..5c073da645d4dcf0934dfce24773d4990f2dac19 100644 (file)
 
       <div class="center more">
         {"More plugins available"|t}
-        <a href="doc/html/Community-&-Related-software/#third-party-plugins">{"in the documentation"|t}</a>.
+        <a href="{$root_path}/doc/html/Community-&-Related-software/#third-party-plugins">{"in the documentation"|t}</a>.
       </div>
       <div class="center">
         <input type="submit" value="{'Save'|t}" name="save">