Skip to content

Mapping Custom Domains to Virtual Plugin Routes

Some plugins — such as FluentCommunity, BuddyPress, and forum plugins — create virtual routes (for example, /portal, /community, /forum) that do not correspond to a physical WordPress page or post in the database. WP Landing Kit maps custom domains to WordPress content objects, so pointing a domain directly at a virtual route causes a redirect loop.

This article explains why the loop occurs and walks you through a workaround using a physical placeholder page and a small PHP redirect snippet.

Why Redirect Loops Happen with Virtual Routes

When you map a custom domain in WP Landing Kit, the plugin resolves the domain to a specific WordPress post, page, or other registered content object. When a visitor arrives at the mapped domain, WP Landing Kit loads that content under the custom domain URL.

Virtual plugin routes work differently. A plugin like FluentCommunity intercepts requests for /portal inside WordPress and serves its own interface — but /portal is not a WordPress page. It has no post ID and cannot be selected as a mapping target in WP Landing Kit.

If you try to map a custom domain directly to /portal, the following loop occurs:

  1. Visitor requests customdomain.com.
  2. WP Landing Kit redirects to /portal on your main site.
  3. The main site redirects back to customdomain.com.
  4. This repeats until the browser reports ERR_TOO_MANY_REDIRECTS.

Workaround: Physical Page + Redirect Snippet

The solution is to:

  1. Create a real WordPress page as a proxy target for WP Landing Kit.
  2. Map your custom domain to that page.
  3. Add a PHP snippet that silently forwards visitors from the placeholder page to the virtual route.

Because WP Landing Kit loads your placeholder page under the custom domain, the PHP snippet runs in that domain context and sends the visitor to the virtual route — without triggering a loop.

Step 1: Create a Placeholder Page

  1. In the WordPress admin, go to Pages > Add New.
  2. Give the page a title such as Community Portal.
  3. Leave the page body empty — its content will never be seen by visitors.
  4. Set the Page Slug (in the URL settings panel) to something like community-portal.
  5. Publish the page.

Step 2: Map Your Custom Domain to the Placeholder Page

  1. Go to WP Landing Kit > All Domains and open the domain you want to configure (or click Add New to create one).
  2. In the Mappings table, expand the Domain Root row.
  3. Set the Resource to the placeholder page you just created (Community Portal).
  4. Save your changes.

Step 3: Add the Redirect Snippet

Add the following code to your theme's functions.php file or to a custom plugin:

php
add_action( 'template_redirect', function() {
    if ( is_page( 'community-portal' ) ) { // Replace with your placeholder page slug or ID
        wp_redirect( home_url( '/portal' ), 302 );
        exit;
    }
} );

Replace 'community-portal' with the slug or numeric ID of your placeholder page, and /portal with the actual virtual route path used by your plugin.

📝 Note: home_url( '/portal' ) builds the URL using your main site URL (the value set in Settings > General > WordPress Address), not the custom domain. This is intentional — the virtual route lives on the main site, and the redirect hands off to the plugin router correctly.

Example: FluentCommunity Portal

If you are using FluentCommunity and want to map community.yourdomain.com to the /portal route:

  1. Create a placeholder page with the slug fluent-portal.
  2. Map community.yourdomain.com to that page in WP Landing Kit.
  3. Add this snippet:
php
add_action( 'template_redirect', function() {
    if ( is_page( 'fluent-portal' ) ) {
        wp_redirect( home_url( '/portal' ), 302 );
        exit;
    }
} );

Visitors who go to community.yourdomain.com are served the placeholder page by WP Landing Kit, then immediately forwarded to /portal where FluentCommunity takes over.

Testing and Caveats

Verify the setup

  1. Visit your custom domain in a browser.
  2. Confirm you land on the virtual route (for example, the FluentCommunity portal) without any redirect error.
  3. Check that the browser does not report ERR_TOO_MANY_REDIRECTS.

Clear caches

If you see unexpected behavior after setting up the redirect, clear:

  • Your browser cache and cookies.
  • Any WordPress caching plugin (for example, WP Rocket, W3 Total Cache, LiteSpeed Cache).
  • Your hosting server cache or CDN cache.

Use 302 (temporary) redirects

The snippet above uses a 302 redirect. This tells browsers and search engines that the redirect is temporary, which prevents them from caching the redirect destination permanently. Once you are satisfied with the setup, you can change 302 to 301 if you want the redirect treated as permanent — but test thoroughly before doing so.

⚠️ Important: Avoid pointing the virtual route path (/portal) back to the mapped domain in any other redirect rule. Any bidirectional redirect between the custom domain and the virtual route will recreate the loop.

Adjust for other virtual routes

This workaround applies to any plugin that uses virtual routing. Replace /portal with the virtual path your plugin uses, and adjust the placeholder page slug to match your setup.