# {organization\_name} based Redirect URI with Apache

**URL:** <https://community.auth0.com/t/organization-name-based-redirect-uri-with-apache/194776>\
**Category:** Get Help\
**Tags:** oidc, protocols\
**Created:** [November 21, 2025, 6:36pm UTC](https://community.auth0.com/t/organization-name-based-redirect-uri-with-apache/194776 "2025-11-21T18:36:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BitshiftNate](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bitshiftnate/32/71938_2.png) [@BitshiftNate](https://community.auth0.com/u/BitshiftNate)\
**Post date:** [November 21, 2025, 6:36pm UTC](https://community.auth0.com/t/organization-name-based-redirect-uri-with-apache/194776/1 "2025-11-21T18:36:16Z")

</div>

Hello all,

I’m currently in the process of creating a B2B SaaS application that requires each customer to have a separate tenant which is an entirely separate server.

I’m running an Apache server to host the front-end that passes API calls back to a Node backend.

My Apache mod\_auth\_openidc configuration is below

OIDCProviderMetadataURL https://[MY DOMAIN].us.auth0.com/.well-known/openid-configuration

OIDCClientID ${APACHE\_OIDC\_CLIENT\_ID}

OIDCClientSecret ${APACHE\_OIDC\_CLIENT\_SECRET}

OIDCScope “openid name email”

OIDCRedirectURI “https://[CLIENT].[PRODUCT NAME].com/redirect-uri”

OIDCCryptoPassphrase ${APACHE\_OIDC\_CRYPTO\_PASSPHRASE}

I have “https://{organization\_name}.[PRODUCT NAME].com/redirect-uri” specified as a valid callback in Auth0, yet when I try to login I get the following error

Callback URL mismatch.  
The provided redirect\_uri is not in the list of allowed callback URLs.  
Please go to the Application Settings page and make sure you are sending a valid callback url from your application.

However, when I hardcode the subdomain for the client in as an allowed redirect uri: https://[CLIENT].[PRODUCT].com/redirect-uri, then it works- however it works for ALL users in my Auth0 domain, not just the ones that are part of the target organization.

Any help would be greatly appreciated, thank you!

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [November 24, 2025, 8:18pm UTC](https://community.auth0.com/t/organization-name-based-redirect-uri-with-apache/194776/3 "2025-11-24T20:18:47Z")

</div>

Hi @BitshiftNate,

Welcome to the Auth0 Community!

The Auth0 Dashboard requires explicit, static URLs in the “Allowed Callback URLs” field. You can’t use a wildcard like `https://{organization_name}.[PRODUCT NAME].com/redirect-uri` or template variables that Auth0 would evaluate. When using an identity provider like Auth0, the `redirect_uri` sent in the initial request needs to match a value configured in the application settings exactly.

The solution to your architecture, where each customer has a distinct, server-side-hosted subdomain, is to route all tenants through a single, static Redirect URI and then handle the post-login routing on your side.

First, change your `mod_auth_openidc` configuration to use a universal, static subdomain that all tenants temporarily hit:

```Apache
OIDCRedirectURI "https://sso.[PRODUCTNAME].com/redirect-uri"

```

In your Auth0 Dashboard, you would then configure only this one URL:

- **Allowed Callback URLs:** `https://sso.[PRODUCT NAME].com/redirect-uri`

After that, you need to tell the user’s browser where to go next (back to their specific tenant subdomain). You can use a **Post-Login Action** to inject this routing information.

Use the user’s `app_metadata` or the context of the login to determine the correct tenant subdomain and then pass that information back to the app.

Here is an example of a **Post-Login Action** :

```JavaScript
/**
 * Handler that will be executed after a successful login
 *
 * @param {Event} event - Details about the login context.
 * @param {PostLoginAPI} api - Interface for interacting with Auth0.
 */
exports.onExecutePostLogin = async (event, api) => {
  // 1. Determine the user's tenant/organization.
  // This logic depends on where you store the tenant ID (e.g., user's app_metadata, a custom database lookup, or an organization ID if using the Organizations feature).

  const userTenant = event.user.app_metadata.tenant_subdomain; // Assuming you store it here

  if (userTenant) {
    // 2. Add the target tenant's subdomain to the ID Token/Access Token.
    // We'll use a custom claim namespace to ensure it's not confused with standard claims.
    const namespace = "https://[PRODUCT NAME].com/claims";
    api.idToken.setCustomClaim(`${namespace}/tenant`, userTenant);
    api.accessToken.setCustomClaim(`${namespace}/tenant`, userTenant);
  }
};

```

After the user is redirected to `https://sso.[PRODUCT NAME].com/redirect-uri`, your Apache server’s `mod_auth_openidc` will receive the token.

- Your server must then **inspect the token** to read the custom `tenant` claim you injected in the Action.
- The server then performs an **internal redirect** (or a 302 redirect back to the client) to the correct, secured URL: `https://[tenant].sso.[PRODUCT NAME].com/dashboard`.

If you have any further questions, please don’t hesitate to reach out.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 8, 2025, 8:19pm UTC](https://community.auth0.com/t/organization-name-based-redirect-uri-with-apache/194776/4 "2025-12-08T20:19:18Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
