Overview
Comment:Move .htaccess to separate files that can be reused in apache config
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA3-256: c2d9f0a2c804f50f83cbbd41debeec1db3988be743d3fdb7fbe08582e68437e2
User & Date: bohwaz on 2023-04-02 15:01:31
Other Links: branch diff | manifest | tags
Context
2023-04-02
15:19
Skip 9 rules, not 10 check-in: d2866c839a user: bohwaz tags: dev
15:01
Move .htaccess to separate files that can be reused in apache config check-in: c2d9f0a2c8 user: bohwaz tags: dev
2023-03-31
11:37
Don't fetch file gallery if we are in excerpt mode check-in: 25e994fc5f user: bohwaz tags: dev
Changes

Modified src/Makefile from [fc09ed5571] to [ea57d2ed4f].

26
27
28
29
30
31
32



33
34
35
36
37
38
39
40
41


42
43
44
45
46
47
48
	@-mkdir vendor
	@-echo '{"require": {}}' > vendor/autoload.php
	psalm.phar -c ../tests/psalm.xml

doc:
	php ../tools/doc_md_to_html.php




release: test minify doc
	$(eval VERSION=$(shell cat VERSION))
	rm -rf /tmp/paheko-build
	mkdir -p /tmp/paheko-build
	fossil zip ${VERSION} /tmp/paheko-build/src.zip --name paheko
	unzip -d /tmp/paheko-build /tmp/paheko-build/src.zip
	cd include/lib; \
		rsync --files-from=dependencies.list -r ./ /tmp/paheko-build/paheko/src/include/lib/
	mv www/admin/static/mini.css /tmp/paheko-build/paheko/src/www/admin/static/admin.css


	cd /tmp/paheko-build/paheko/src/www/admin/static; \
		rm -f styles/[0-9]*.css; \
		rm -f font/*.css font/*.json
	cd /tmp/paheko-build/paheko/src; \
		rm -f Makefile include/lib/KD2/data/countries.en.json
	cd /tmp/paheko-build/paheko/src/data; mkdir plugins && cd plugins; \
		wget https://fossil.kd2.org/paheko-plugins/uv/welcome.tar.gz \







>
>
>









>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	@-mkdir vendor
	@-echo '{"require": {}}' > vendor/autoload.php
	psalm.phar -c ../tests/psalm.xml

doc:
	php ../tools/doc_md_to_html.php

www/.htaccess:
	cat apache-vhost.conf apache-htaccess.conf > www/.htaccess

release: test minify doc
	$(eval VERSION=$(shell cat VERSION))
	rm -rf /tmp/paheko-build
	mkdir -p /tmp/paheko-build
	fossil zip ${VERSION} /tmp/paheko-build/src.zip --name paheko
	unzip -d /tmp/paheko-build /tmp/paheko-build/src.zip
	cd include/lib; \
		rsync --files-from=dependencies.list -r ./ /tmp/paheko-build/paheko/src/include/lib/
	mv www/admin/static/mini.css /tmp/paheko-build/paheko/src/www/admin/static/admin.css
	# Generate .htaccess file
	cd /tmp/paheko-build/paheko/src && make www/.htaccess
	cd /tmp/paheko-build/paheko/src/www/admin/static; \
		rm -f styles/[0-9]*.css; \
		rm -f font/*.css font/*.json
	cd /tmp/paheko-build/paheko/src; \
		rm -f Makefile include/lib/KD2/data/countries.en.json
	cd /tmp/paheko-build/paheko/src/data; mkdir plugins && cd plugins; \
		wget https://fossil.kd2.org/paheko-plugins/uv/welcome.tar.gz \

Modified src/apache-htaccess.conf from [16f341b60e] to [de974946e4].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Options -Indexes -Multiviews +FollowSymlinks

# Explication : FallbackResource n'est dispo que depuis Apache 2.2.16, soit Debian Wheezy (2013)
# Mais bugue avant Apache 2.4.15, il faut donc bien désactiver le DirectoryIndex
# cf. https://bz.apache.org/bugzilla/show_bug.cgi?id=58292
# et https://serverfault.com/questions/559067/apache-hangs-for-five-seconds-with-fallbackresource-when-accessing
DirectoryIndex disabled
DirectoryIndex index.php

# Un peu de sécurité
<IfModule mod_alias.c>
	RedirectMatch 404 _inc\.php
</IfModule>

# This is to avoid caching mismatch when using mod_deflate
# see https://github.com/symfony/symfony-docs/issues/12644
<IfModule mod_deflate.c>
	FileETag None
</IfModule>

# Décommenter les lignes suivantes pour autoriser l'envoi de gros fichier jusqu'à 256 Mo
# (documents et sauvegardes)
#
#<If "%{REQUEST_URI} =~ m!^/admin/(common/files|config/backup)/! && -n %{HTTP_COOKIE}">
#	php_value post_max_size 256M
#	php_value upload_max_filesize 256M
#</If>

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /

	RewriteRule \.cache - [R=404]

	# Do not try to get from cache if URL is private, or belongs to modules/plugins
	RewriteCond %{REQUEST_URI} admin/|dav/|wopi/|ocs|avatars|p/|api/|documents/|user/|transaction/|m/|\.php$ [OR]
	# Do not try cache if method is not GET or HEAD
	RewriteCond %{REQUEST_METHOD} !GET|HEAD
	# Skip, go to router directly
	RewriteRule ^ - [skip=7]

	# Store MD5 hashes in environment variables
	RewriteCond %{REQUEST_URI} ^(.+)(?:\?|$)
	RewriteRule ^ "-" [E=CACHE_URI:%1]
	# Extract file extension (required for Apache to serve the correct mimetype)
	RewriteCond %{REQUEST_URI} (\.[a-z0-9]+)(?:\?|$)
	RewriteRule ^ "-" [E=CACHE_EXT:%1]
	# If no extension, default to .html
	RewriteCond %{REQUEST_URI} !\.[a-z0-9]+(?:\?|$)
	RewriteRule ^ "-" [E=CACHE_EXT:.html]
	RewriteCond expr "md5(%{ENV:CACHE_URI}) =~ /^(.+)$/"
	RewriteRule ^ "-" [E=CACHE_URI_MD5:%1]
	RewriteCond expr "md5(tolower(%{HTTP_HOST})) =~ /^((.{2}).+)$/"
	RewriteRule ^ "-" [E=CACHE_HOST_MD5:%1,E=CACHE_HOST2_MD5:%2]
	RewriteCond /.cache/%{ENV:CACHE_HOST_MD5}/%{ENV:CACHE_URI_MD5} (.+)
	RewriteRule ^ "-" [E=CACHE_PATH:%1]

	# Serve static file for resized images
	RewriteCond %{QUERY_STRING} (?:^|&)(\d+px(?:-[a-z]+)?)
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}_%1%{ENV:CACHE_EXT} -l
	RewriteRule ^ %{ENV:CACHE_PATH}_%1%{ENV:CACHE_EXT} [END]

	# Serve linked files for other URIs
	RewriteCond %{QUERY_STRING} ="" [OR]
	RewriteCond %{QUERY_STRING} ^h=[a-f0-9]+$
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} -l
	RewriteRule ^ %{ENV:CACHE_PATH}%{ENV:CACHE_EXT} [END]

	# Do not try cache for pages if user is logged-in
	RewriteCond %{HTTP_COOKIE} !pko
	# Serve static HTML pages
	RewriteCond %{QUERY_STRING} =""
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} -f
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} !-l
	RewriteRule ^ %{ENV:CACHE_PATH}%{ENV:CACHE_EXT} [END]

	# Redirect to router
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^.*$ /_route.php [END,QSA]
</IfModule>

# Sinon le reste marchera, sauf les clients OC/NC
<IfModule !mod_rewrite.c>
	# Rediriger les adresses dynamiques vers le routeur
	FallbackResource /_route.php

	# FallbackResource ne fonctionne pas pour les URLs en .php
	# voir https://stackoverflow.com/a/66136226
	ErrorDocument 404 /_route.php

	# Les clients NextCloud/ownCloud ne peuvent fonctionner sans mod_rewrite
	<IfModule mod_alias.c>
		Redirect 501 /remote.php
		Redirect 501 /status.php
	</IfModule>
</IfModule>
|
|
|
<
|
|
|
|

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<


|
|


|





1
2
3

4
5
6
7
8



































































9








10
11
12
13
14
15
16
17
18
19
20
21
# Sinon le reste marchera, sauf les clients OC/NC
<IfModule !mod_rewrite.c>
	# FallbackResource has a bug before Apache 2.4.15, requiring to disable DirectoryIndex

	# see https://bz.apache.org/bugzilla/show_bug.cgi?id=58292
	# and https://serverfault.com/questions/559067/apache-hangs-for-five-seconds-with-fallbackresource-when-accessing
	DirectoryIndex disabled
	DirectoryIndex index.php




































































	# Redirect non-existing URLs to the router








	FallbackResource /_route.php

	# FallbackResource does not work for URLs ending with ".php"
	# see https://stackoverflow.com/a/66136226
	ErrorDocument 404 /_route.php

	# NextCloud/ownCloud clients cannot work without mod_rewrite
	<IfModule mod_alias.c>
		Redirect 501 /remote.php
		Redirect 501 /status.php
	</IfModule>
</IfModule>

Added src/apache-vhost.conf version [1e22905a3e].







































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Options -Indexes -Multiviews +FollowSymlinks

<IfModule mod_php.c>
	Define PHP_MODULE
</IfModule>

<IfModule mod_php7.c>
	Define PHP_MODULE
</IfModule>

# Some security
<IfModule mod_alias.c>
	RedirectMatch 404 _inc\.php
</IfModule>

# Recommended, if you have xsendfile module
# see https://tn123.org/mod_xsendfile/
# Also enable X-SendFile in config.local.php
#
#<IfModule mod_xsendfile.c>
#	<Files *.php>
#		XSendFile On
#		XSendFilePath /home/paheko/
#	</Files>
#</IfModule>

# This is to avoid caching mismatch when using mod_deflate
# see https://github.com/symfony/symfony-docs/issues/12644
<IfModule mod_deflate.c>
	FileETag None
</IfModule>

# Allow uploads up to 256 MB where it's required
<If "%{REQUEST_URI} =~ m!^/admin/(?:common/files|config/backup)/|^/(?:web)?dav/|^/remote\.php/(?:web)?dav/! && -n %{HTTP_COOKIE}">
	<IfDefine PHP_MODULE>
		php_value post_max_size 256M
		php_value upload_max_filesize 256M
	</IfDefine>
	<IfDefine !PHP_MODULE>
		SetEnv PHP_VALUE "post_max_size=256M"
		# There is no way to pass multiple PHP ini settings via PHP_VALUE :-(
		# so we use PHP_ADMIN_VALUE here. It works unless we have more than 2 settings to change.
		SetEnv PHP_ADMIN_VALUE "upload_max_filesize=256M"
	</IfDefine>
</If>

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /

	RewriteRule \.cache - [R=404]

	# Do not try to get from cache if URL is private, or belongs to modules/plugins
	RewriteCond %{REQUEST_URI} admin/|dav/|wopi/|ocs|avatars|p/|api/|documents/|user/|transaction/|m/|\.php$ [OR]
	# Do not try cache if method is not GET or HEAD
	RewriteCond %{REQUEST_METHOD} !GET|HEAD
	# Skip, go to router directly
	RewriteRule ^ - [skip=10]

	# Store MD5 hashes in environment variables
	RewriteCond %{REQUEST_URI} ^(.+)(?:\?|$)
	RewriteRule ^ "-" [E=CACHE_URI:%1]
	# Extract file extension (required for Apache to serve the correct mimetype)
	RewriteCond %{REQUEST_URI} (\.[a-z0-9]+)(?:\?|$)
	RewriteRule ^ "-" [E=CACHE_EXT:%1]
	# If no extension, default to .html
	RewriteCond %{REQUEST_URI} !\.[a-z0-9]+(?:\?|$)
	RewriteRule ^ "-" [E=CACHE_EXT:.html]
	RewriteCond expr "md5(%{ENV:CACHE_URI}) =~ /^(.+)$/"
	RewriteRule ^ "-" [E=CACHE_URI_MD5:%1]
	RewriteCond expr "md5(tolower(%{HTTP_HOST})) =~ /^((.{2}).+)$/"
	RewriteRule ^ "-" [E=CACHE_HOST_MD5:%1,E=CACHE_HOST2_MD5:%2]
	RewriteCond /.cache/%{ENV:CACHE_HOST_MD5}/%{ENV:CACHE_URI_MD5} (.+)
	RewriteRule ^ "-" [E=CACHE_PATH:%1]

	# Serve static file for resized images
	RewriteCond %{QUERY_STRING} (?:^|&)(\d+px(?:-[a-z]+)?)
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}_%1%{ENV:CACHE_EXT} -l
	RewriteRule ^ %{ENV:CACHE_PATH}_%1%{ENV:CACHE_EXT} [END]

	# Serve linked files for other URIs
	RewriteCond %{QUERY_STRING} ="" [OR]
	RewriteCond %{QUERY_STRING} ^h=[a-f0-9]+$
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} -l
	RewriteRule ^ %{ENV:CACHE_PATH}%{ENV:CACHE_EXT} [END]

	# Do not try cache for pages if user is logged-in
	RewriteCond %{HTTP_COOKIE} !pko
	# Serve static HTML pages
	RewriteCond %{QUERY_STRING} =""
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} -f
	RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} !-l
	RewriteRule ^ %{ENV:CACHE_PATH}%{ENV:CACHE_EXT} [END]

	# Redirect to router
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^.*$ /_route.php [END,QSA]
</IfModule>