:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat: redirect /sign-up to /signup (#60468)
Joe Martin79d215097bf7
diff --git a/posthog/test/test_urls.py b/posthog/test/test_urls.pyindex 9253fd641c27..bdf5bb604ae5 100644--- a/posthog/test/test_urls.py+++ b/posthog/test/test_urls.py@@ -46,6 +46,20 @@ class TestUrls(APIBaseTest):response = self.client.get(f"/login")self.assertEqual(response.status_code, status.HTTP_200_OK)+ @parameterized.expand(+ [+ ("no_slash_no_qs", "/sign-up", "/signup"),+ ("trailing_slash_no_qs", "/sign-up/", "/signup"),+ ("no_slash_with_qs", "/sign-up?email=foo%40bar.com", "/signup?email=foo%40bar.com"),+ ("trailing_slash_with_qs", "/sign-up/?email=foo%40bar.com", "/signup?email=foo%40bar.com"),+ ]+ )+ def test_sign_up_redirects_to_signup(self, _name, request_path, expected_location):+ self.client.logout()+ response = self.client.get(request_path, follow=False)+ self.assertEqual(response.status_code, status.HTTP_301_MOVED_PERMANENTLY)+ self.assertEqual(response["Location"], expected_location)+@parameterized.expand([("no_query_string", "/admin", "/admin/"),diff --git a/posthog/urls.py b/posthog/urls.pyindex 7f30c1c3e8c3..7bad4db9fadf 100644--- a/posthog/urls.py+++ b/posthog/urls.py@@ -7,6 +7,7 @@ from django.template import loaderfrom django.urls import include, path, re_pathfrom django.utils.http import url_has_allowed_host_and_schemefrom django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie, requires_csrf_token+from django.views.generic.base import RedirectViewimport structlogfrom drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView@@ -476,6 +477,13 @@ if settings.TEST:urlpatterns.append(path("decode", decode_payloads, name="temporal_decode"))+# Redirect the legacy `/sign-up` path to the canonical `/signup` route. Works across+# app./us./eu. subdomains because only the path changes; the host is preserved by the+# relative redirect.+urlpatterns.append(+ opt_slash_path("sign-up", RedirectView.as_view(url="/signup", permanent=True, query_string=True)),+)+# Routes added individually to remove login requirementfrontend_unauthenticated_routes = ["preflight",