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 5a4a58f64f Add script to check redirects
5a4a58f64f is described below

commit 5a4a58f64f1f2be9d450257799502ea9730acab6
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Thu May 30 14:39:08 2024 +0200

    Add script to check redirects
---
 src/site/resources/.htaccess | 27 +++++++++++++-------
 src/tools/check-redirects.sh | 31 +++++++++++++++++++++++
 src/tools/redirects.txt      | 60 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+), 9 deletions(-)

diff --git a/src/site/resources/.htaccess b/src/site/resources/.htaccess
index b3d3352d02..1c15064b2c 100644
--- a/src/site/resources/.htaccess
+++ b/src/site/resources/.htaccess
@@ -35,17 +35,24 @@ RewriteRule "^(.+)$" "$1.html"
 RewriteRule "^articles\.html$" "manual/index.html" [R=permanent]
 RewriteRule "^log4j-api/apidocs(.*)$" "javadoc/log4j-api$1" [R=permanent]
 RewriteRule "^log4j-api/index\.html$" "manual/api.html" [R=permanent]
+RewriteRule "^log4j-api\.html$" "manual/api.html" [R=permanent]
 RewriteRule "^log4j-core/apidocs(.*)$" "javadoc/log4j-core$1" [R=permanent]
-RewriteRule "^log4j-jcl/index\.html$" 
"manual/installation.html#impl-core-bridge-jcl" [R=permanent]
+RewriteRule "^log4j-jcl/index\.html$" 
"manual/installation.html#impl-core-bridge-jcl" [R=permanent,NE]
+RewriteRule "^log4j-jcl\.html$" 
"manual/installation.html#impl-core-bridge-jcl" [R=permanent,NE]
 RewriteRule "^log4j-jmx-gui/index\.html$" "/log4j/jmx-gui/latest/index.html" 
[R=permanent]
-RewriteRule "^log4j-jpl/index\.html$" 
"manual/installation.html#impl-core-bridge-jpl" [R=permanent]
-RewriteRule "^log4j-jul/index\.html$" 
"manual/installation.html#impl-core-bridge-jul" [R=permanent]
-RewriteRule "^log4j-mongodb3\.html$" 
"manual/appenders.html#NoSQLAppenderMongoDB" [R=permanent]
-RewriteRule "^log4j-mongodb3/index\.html$" 
"manual/appenders.html#NoSQLAppenderMongoDB" [R=permanent]
-RewriteRule "^log4j-mongodb4\.html$" "manual/appenders.html#log4j-mongodb4" 
[R=permanent]
-RewriteRule "^log4j-mongodb4/index\.html$" 
"manual/appenders.html#log4j-mongodb4" [R=permanent]
-RewriteRule "^log4j-slf4j-impl/index\.html$" 
"manual/installation.html#impl-core-bridge-slf4j" [R=permanent]
-RewriteRule "^log4j-slf4j2-impl/index\.html$" 
"manual/installation.html#impl-core-bridge-slf4j" [R=permanent]
+RewriteRule "^log4j-jmx-gui\.html$" "/log4j/jmx-gui/latest/index.html" 
[R=permanent]
+RewriteRule "^log4j-jpl/index\.html$" 
"manual/installation.html#impl-core-bridge-jpl" [R=permanent,NE]
+RewriteRule "^log4j-jpl\.html$" 
"manual/installation.html#impl-core-bridge-jpl" [R=permanent,NE]
+RewriteRule "^log4j-jul/index\.html$" 
"manual/installation.html#impl-core-bridge-jul" [R=permanent,NE]
+RewriteRule "^log4j-jul\.html$" 
"manual/installation.html#impl-core-bridge-jul" [R=permanent,NE]
+RewriteRule "^log4j-mongodb3\.html$" 
"manual/appenders.html#NoSQLAppenderMongoDB" [R=permanent,NE]
+RewriteRule "^log4j-mongodb3/index\.html$" 
"manual/appenders.html#NoSQLAppenderMongoDB" [R=permanent,NE]
+RewriteRule "^log4j-mongodb4\.html$" "manual/appenders.html#log4j-mongodb4" 
[R=permanent,NE]
+RewriteRule "^log4j-mongodb4/index\.html$" 
"manual/appenders.html#log4j-mongodb4" [R=permanent,NE]
+RewriteRule "^log4j-slf4j-impl/index\.html$" 
"manual/installation.html#impl-core-bridge-slf4j" [R=permanent,NE]
+RewriteRule "^log4j-slf4j-impl\.html$" 
"manual/installation.html#impl-core-bridge-slf4j" [R=permanent,NE]
+RewriteRule "^log4j-slf4j2-impl/index\.html$" 
"manual/installation.html#impl-core-bridge-slf4j" [R=permanent,NE]
+RewriteRule "^log4j-slf4j2-impl\.html$" 
"manual/installation.html#impl-core-bridge-slf4j" [R=permanent,NE]
 RewriteRule "^manual/api-separation\.html$" "manual/api.html" [R=permanent]
 RewriteRule "^manual/scala-api\.html$" "/log4j/scala/latest/index.html" 
[R=permanent]
 RewriteRule "^manual/usage\.html$" "manual/api.html" [R=permanent]
@@ -70,3 +77,5 @@ RewriteRule "^log4j-jakarta-web\.html/index\.html$" 
"log4j-jakarta-web.html" [R=
 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]
+RewriteRule "^log4j-taglib\.html/index\.html$" "log4j-taglib.html" 
[R=permanent]
+RewriteRule "^log4j-web\.html/index\.html$" "log4j-web.html" [R=permanent]
diff --git a/src/tools/check-redirects.sh b/src/tools/check-redirects.sh
new file mode 100755
index 0000000000..ef60f914f3
--- /dev/null
+++ b/src/tools/check-redirects.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Checks the permanent redirects for a given site.
+# Usage:
+#
+# check-redirects logging.staged.apache.org
+#
+
+BASE_DIR=$(dirname $0)
+HOST=$1
+
+if [ "$HOST" == "" ]; then
+  HOST=logging.apache.org
+fi
+
+while read -r src dst; do
+  case $src in
+    \#*)
+      ;;
+    *)
+      actual_dst=$(curl -s -I "https://$HOST$src"; | grep --color=never -Po 
'(?<=Location: ).*' | tr -d [[:cntrl:]])
+      if [ "$actual_dst" != "https://$HOST$dst"; ]; then
+        echo "Expecting '$src' to redirect to"
+        echo -e "\t'https://$HOST$dst'"
+        echo "but was"
+        echo -e "\t'$actual_dst'";
+      fi
+      ;;
+  esac
+done < $BASE_DIR/redirects.txt
+
diff --git a/src/tools/redirects.txt b/src/tools/redirects.txt
new file mode 100644
index 0000000000..7276736218
--- /dev/null
+++ b/src/tools/redirects.txt
@@ -0,0 +1,60 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+##
+# List of site redirects to check
+/log4j/2.x/articles.html /log4j/2.x/manual/index.html
+/log4j/2.x/log4j-1.2-api/index.html /log4j/2.x/log4j-1.2-api.html
+/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/Logger.html 
/log4j/2.x/javadoc/log4j-api/org/apache/logging/log4j/Logger.html
+/log4j/2.x/log4j-api/index.html /log4j/2.x/manual/api.html
+/log4j/2.x/log4j-api.html /log4j/2.x/manual/api.html
+/log4j/2.x/log4j-appserver/index.html /log4j/2.x/log4j-appserver.html
+/log4j/2.x/log4j-cassandra/index.html /log4j/2.x/log4j-cassandra.html
+/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/LoggerContext.html 
/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/LoggerContext.html
+/log4j/2.x/log4j-couchdb/index.html /log4j/2.x/log4j-couchdb.html
+/log4j/2.x/log4j-docker/index.html /log4j/2.x/log4j-docker.html
+/log4j/2.x/log4j-flume-ng/index.html /log4j/2.x/log4j-flume-ng.html
+/log4j/2.x/log4j-iostreams/index.html /log4j/2.x/log4j-iostreams.html
+/log4j/2.x/log4j-jakarta-web/index.html /log4j/2.x/log4j-jakarta-web.html
+/log4j/2.x/log4j-jcl/index.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-jcl
+/log4j/2.x/log4j-jcl.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-jcl
+/log4j/2.x/log4j-jmx-gui/index.html /log4j/jmx-gui/latest/index.html
+/log4j/2.x/log4j-jmx-gui.html /log4j/jmx-gui/latest/index.html
+/log4j/2.x/log4j-jpl/index.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-jpl
+/log4j/2.x/log4j-jpl.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-jpl
+/log4j/2.x/log4j-jul/index.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-jul
+/log4j/2.x/log4j-jul.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-jul
+/log4j/2.x/log4j-mongodb3/index.html 
/log4j/2.x/manual/appenders.html#NoSQLAppenderMongoDB
+/log4j/2.x/log4j-mongodb3.html 
/log4j/2.x/manual/appenders.html#NoSQLAppenderMongoDB
+/log4j/2.x/log4j-mongodb4/index.html 
/log4j/2.x/manual/appenders.html#log4j-mongodb4
+/log4j/2.x/log4j-mongodb4.html /log4j/2.x/manual/appenders.html#log4j-mongodb4
+/log4j/2.x/log4j-slf4j-impl/index.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-slf4j
+/log4j/2.x/log4j-slf4j-impl.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-slf4j
+/log4j/2.x/log4j-slf4j2-impl/index.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-slf4j
+/log4j/2.x/log4j-slf4j2-impl.html 
/log4j/2.x/manual/installation.html#impl-core-bridge-slf4j
+/log4j/2.x/api-separation.html /log4j/2.x/manual/api.html
+/log4j/2.x/scala-api.html /log4j/scala/latest/index.html
+/log4j/2.x/usage.html /log4j/2.x/manual/api.html
+/log4j/2.x/release-notes/index.html /log4j/2.x/release-notes.html
+/log4j/2.x/runtime-dependencies.html /log4j/2.x/manual/installation.html
+/log4j/2.x/log4j-spring-boot/index.html /log4j/2.x/log4j-spring-boot.html
+/log4j/2.x/log4j-spring-cloud-config/index.html 
/log4j/2.x/log4j-spring-cloud-config.html
+/log4j/2.x/log4j-spring-cloud-config-client/index.html 
/log4j/2.x/log4j-spring-cloud-config-client.html
+/log4j/2.x/thanks.html /log4j/2.x/support.html#sponsors
+/log4j/2.x/log4j-taglib/index.html /log4j/2.x/log4j-taglib.html
+/log4j/2.x/log4j-web/index.html /log4j/2.x/web.html

Reply via email to