Well-known URLs: Difference between revisions

From Davical
Jump to navigationJump to search
(Undo revision 3520 by Gorka (talk) Moving page rather than deleting it)
 
(One intermediate revision by one other user not shown)
Line 3: Line 3:
To activate well-known URLs, you have to edit the apache config. To use the following snippets, you have to activate mod_rewrite.
To activate well-known URLs, you have to edit the apache config. To use the following snippets, you have to activate mod_rewrite.


===Possibility a: redirect everything===
===Possibility A: redirect only collections ===
#Activate RewriteEngine
RewriteEngine On
# Filter paths with no known file extension
RewriteCond %{REQUEST_URI} !\.css
RewriteCond %{REQUEST_URI} !\.gif
RewriteCond %{REQUEST_URI} !\.jpg
RewriteCond %{REQUEST_URI} !\.png
RewriteCond %{REQUEST_URI} !\.js
RewriteCond %{REQUEST_URI} !\.php
RewriteCond %{REQUEST_URI} !\.html
RewriteCond %{REQUEST_URI} !\.txt
RewriteCond %{REQUEST_URI} ^/..*/
# and redirect them to our caldav.php
RewriteRule ^(.*)$ /caldav.php/$1 [NC,L]
 
===Possibility B: redirect everything===


  #Activate RewriteEngine
  #Activate RewriteEngine
Line 27: Line 43:
This configuration does not work together with other programs using mod_rewrite. As a side effect,
This configuration does not work together with other programs using mod_rewrite. As a side effect,


===Possibility b: redirect .well-known only===
===Possibility C: redirect .well-known only===


  #Activate RewriteEngine
  #Activate RewriteEngine

Latest revision as of 18:42, 2 June 2021

Template:Languages

Apache

To activate well-known URLs, you have to edit the apache config. To use the following snippets, you have to activate mod_rewrite.

Possibility A: redirect only collections

#Activate RewriteEngine
RewriteEngine On
# Filter paths with no known file extension
RewriteCond %{REQUEST_URI} !\.css
RewriteCond %{REQUEST_URI} !\.gif
RewriteCond %{REQUEST_URI} !\.jpg
RewriteCond %{REQUEST_URI} !\.png
RewriteCond %{REQUEST_URI} !\.js
RewriteCond %{REQUEST_URI} !\.php
RewriteCond %{REQUEST_URI} !\.html
RewriteCond %{REQUEST_URI} !\.txt
RewriteCond %{REQUEST_URI} ^/..*/
# and redirect them to our caldav.php
RewriteRule ^(.*)$ /caldav.php/$1 [NC,L]

Possibility B: redirect everything

#Activate RewriteEngine
RewriteEngine On
# Filter all files that do not exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# and redirect them to our caldav.php
RewriteRule ^(.*)$ /caldav.php/$1 [NC,L]


Under Apache 2.3 and if you put that in your site configuration (same as httpd.conf) you should rather use that :

#Activate RewriteEngine
RewriteEngine On
# Filter all files that do not exist
RewriteCond %{LA-U:REQUEST_FILENAME} !-f
RewriteCond %{LA-U:REQUEST_FILENAME} !-d
# and redirect them to our caldav.php
RewriteRule ^(.*)$ /caldav.php/$1 [NC,L]


This configuration does not work together with other programs using mod_rewrite. As a side effect,

Possibility C: redirect .well-known only

#Activate RewriteEngine
RewriteEngine On
# Redirect /.well-known URLs
RewriteRule ^/\.well-known/(.*)$ /caldav.php/.well-known/$1 [NC,L]
# Optionally: redirect /principals/users/ as well
RewriteRule ^/principals/users/(.*)$ /caldav.php/$1 [NC,L]

This configuration does not include the forwards to calendars (/username/calendarname instead of /caldav.php/username/calendarname).