diff --git a/airflow-core/docs/redirects.txt b/airflow-core/docs/redirects.txt index fec740e5fa31f..582cbe90c1542 100644 --- a/airflow-core/docs/redirects.txt +++ b/airflow-core/docs/redirects.txt @@ -184,5 +184,5 @@ howto/operator/python.rst ../../apache-airflow-providers-standard/stable/operato howto/operator/time.rst ../../apache-airflow-providers-standard/stable/sensors/datetime.rst howto/operator/weekday.rst ../../apache-airflow-providers-standard/stable/operators/datetime.rst#branchdayofweekoperator -_api/airflow/operators/datetime/index.html ../apache-airflow-providers-standard/stable/_api/airflow/providers/standard/operators/datetime/index.html -_api/airflow/operators/empty/index.html ../apache-airflow-providers-standard/stable/_api/airflow/providers/standard/operators/empty/index.html +_api/airflow/operators/datetime/index.html ../../apache-airflow-providers-standard/stable/_api/airflow/providers/standard/operators/datetime/index.html +_api/airflow/operators/empty/index.html ../../apache-airflow-providers-standard/stable/_api/airflow/providers/standard/operators/empty/index.html diff --git a/devel-common/src/sphinx_exts/redirects.py b/devel-common/src/sphinx_exts/redirects.py index 95e6de2121004..f9345c58ba984 100644 --- a/devel-common/src/sphinx_exts/redirects.py +++ b/devel-common/src/sphinx_exts/redirects.py @@ -62,7 +62,13 @@ def generate_redirects(app): to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep)) - 1) # The redirect path needs to move back to the root of the apache-airflow docs directory # or the root of the docs directory altogether for provider distributions. - if "../" and "providers" in to_path: + if ( + from_path.startswith("_api/airflow/") + and "_api/airflow/providers" not in from_path + and "providers" in to_path + ): + to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep)) - 1) + elif "../" and "providers" in to_path: to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep))) else: to_path_prefix = f"..{os.path.sep}" * (len(from_path.split(os.path.sep)) - 1)