This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/2.x by this push:
new 676f03a4c4 Fix redirects
676f03a4c4 is described below
commit 676f03a4c4ff9ae81d7a0422468d2addfcf36d60
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Fri May 24 23:06:51 2024 +0200
Fix redirects
---
src/site/resources/.htaccess | 58 +++++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 27 deletions(-)
diff --git a/src/site/resources/.htaccess b/src/site/resources/.htaccess
index ec2dfaf963..47f907b75d 100644
--- a/src/site/resources/.htaccess
+++ b/src/site/resources/.htaccess
@@ -22,43 +22,47 @@ RewriteBase "/log4j/2.x/"
##
# To simplify the redirection rules, we normalized them:
#
-# 1. If the request URIs points to a (non-existent) directory, we add
`index.html` to it
-RewriteCond %{REQUEST_FILENAME} !-d
+# 1. If the request URIs ends in `/` (necessarily a `path-info`), we add
`index.html` to it:
RewriteRule "^(.*)/$" "$1/index.html" [DPI]
-# 2. If the request URI points to a (non-existent) file, we make sure it ends
with `.html`:
+# 2. If the request URI points to a (non-existent) file, we try adding `.html`:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 "!\.html$"
-RewriteRule "^(.*)$" "$1.html"
+RewriteRule "^(.+)$" "$1.html"
#
# From this point rules match against the URI to the real file, with
"/log4j/2.x/" stripped.
-RewriteRule "^log4j-(core|api)/apidocs(.*)$" "javadoc/log4j-$1$2" [R=permanent]
-
# The content moved between pages
+RewriteRule "^log4j-core/apidocs(.*)$" "javadoc/log4j-core$1" [R=permanent]
RewriteRule "^manual/api-separation\.html$" "manual/api.html" [R=permanent]
RewriteRule "^manual/scala-api\.html$" "/log4j/scala/index.html" [R=permanent]
RewriteRule "^manual/usage\.html$" "manual/api.html" [R=permanent]
RewriteRule "^release-notes/index\.html$" "release-notes.html" [R=permanent]
RewriteRule "^runtime-dependencies\.html$" "manual/installation.html"
[R=permanent]
-# Redirect old per-module directories to files
-RewriteRule "^log4j-1\.2-api/index\.html$" "log4j-1.2-api.html" [R=permanent]
-RewriteRule "^log4j-api/index\.html$" "log4j-api.html" [R=permanent]
-RewriteRule "^log4j-appserver/index\.html$" "log4j-appserver.html"
[R=permanent]
-RewriteRule "^log4j-cassandra/index\.html$" "log4j-cassandra.html"
[R=permanent]
-RewriteRule "^log4j-couchdb/index\.html$" "log4j-couchdb.html" [R=permanent]
-RewriteRule "^log4j-docker/index\.html$" "log4j-docker.html" [R=permanent]
-RewriteRule "^log4j-flume-ng/index\.html$" "log4j-flume-ng.html" [R=permanent]
-RewriteRule "^log4j-iostreams/index\.html$" "log4j-iostreams.html"
[R=permanent]
-RewriteRule "^log4j-jakarta-web/index\.html$" "log4j-jakarta-web.html"
[R=permanent]
-RewriteRule "^log4j-jcl/index\.html$" "log4j-jcl.html" [R=permanent]
-RewriteRule "^log4j-jmx-gui/index\.html$" "log4j-jmx-gui.html" [R=permanent]
-RewriteRule "^log4j-jpl/index\.html$" "log4j-jpl.html" [R=permanent]
-RewriteRule "^log4j-jul/index\.html$" "log4j-jul.html" [R=permanent]
-RewriteRule "^log4j-mongodb3/index\.html$" "log4j-mongodb3.html" [R=permanent]
-RewriteRule "^log4j-mongodb4/index\.html$" "log4j-mongodb4.html" [R=permanent]
-RewriteRule "^log4j-slf4j-impl/index\.html$" "log4j-slf4j-impl.html"
[R=permanent]
-RewriteRule "^log4j-slf4j2-impl/index\.html$" "log4j-slf4j2-impl.html"
[R=permanent]
-RewriteRule "^log4j-spring-boot/index\.html$" "log4j-spring-boot.html"
[R=permanent]
-RewriteRule "^log4j-spring-cloud-config/index\.html$"
"log4j-spring-cloud-config.html" [R=permanent]
-RewriteRule "^log4j-spring-cloud-config-client/index\.html$"
"log4j-spring-cloud-config-client.html" [R=permanent]
+# These redirects are special, since:
+#
+# 1. `mod_negotiate` is active and it is applied before `mod_rewrite`,
+# 2. we replaced a directory like `log4j-api/` with a file that has the same
prefix like `log4j-api.html`,
+#
+# if the URI path is `/log4j/2.x/log4j-api/foo` we must match
`log4j-api.html/foo`.
+RewriteRule "^log4j-1\.2-api\.html/index\.html$" "log4j-1.2-api.html"
[R=permanent]
+RewriteRule "^log4j-api\.html/apidocs(.*)$" "javadoc/log4j-api$1" [R=permanent]
+RewriteRule "^log4j-api\.html/index\.html" "log4j-api.html" [R=permanent]
+RewriteRule "^log4j-appserver\.html/index\.html$" "log4j-appserver.html"
[R=permanent]
+RewriteRule "^log4j-cassandra\.html/index\.html$" "log4j-cassandra.html"
[R=permanent]
+RewriteRule "^log4j-couchdb\.html/index\.html$" "log4j-couchdb.html"
[R=permanent]
+RewriteRule "^log4j-docker\.html/index\.html$" "log4j-docker.html"
[R=permanent]
+RewriteRule "^log4j-flume-ng\.html/index\.html$" "log4j-flume-ng.html"
[R=permanent]
+RewriteRule "^log4j-iostreams\.html/index\.html$" "log4j-iostreams.html"
[R=permanent]
+RewriteRule "^log4j-jakarta-web\.html/index\.html$" "log4j-jakarta-web.html"
[R=permanent]
+RewriteRule "^log4j-jcl\.html/index\.html$" "log4j-jcl.html" [R=permanent]
+RewriteRule "^log4j-jmx-gui\.html/index\.html$" "log4j-jmx-gui.html"
[R=permanent]
+RewriteRule "^log4j-jpl\.html/index\.html$" "log4j-jpl.html" [R=permanent]
+RewriteRule "^log4j-jul\.html/index\.html$" "log4j-jul.html" [R=permanent]
+RewriteRule "^log4j-mongodb3\.html/index\.html$" "log4j-mongodb3.html"
[R=permanent]
+RewriteRule "^log4j-mongodb4\.html/index\.html$" "log4j-mongodb4.html"
[R=permanent]
+RewriteRule "^log4j-slf4j-impl\.html/index\.html$" "log4j-slf4j-impl.html"
[R=permanent]
+RewriteRule "^log4j-slf4j2-impl\.html/index\.html$" "log4j-slf4j2-impl.html"
[R=permanent]
+RewriteRule "^log4j-spring-boot\.html/index\.html$" "log4j-spring-boot.html"
[R=permanent]
+RewriteRule "^log4j-spring-cloud-config\.html/index\.html$"
"log4j-spring-cloud-config.html" [R=permanent]
+RewriteRule "^log4j-spring-cloud-config-client\.html/index\.html$"
"log4j-spring-cloud-config-client.html" [R=permanent]