Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8219115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:02:55+00:00 2026-06-07T13:02:55+00:00

On my site, users have public profiles that can be accessed via http://mysite.com/vanity_url .

  • 0

On my site, users have public profiles that can be accessed via http://mysite.com/vanity_url. I want to allow users to point their own domains to their profile page on my site. Just like Bandcamp does.

My Profile model has these two fields to deal with this: vanity_url, which is the normal username type of field; and a new custom_domain which is their own domains’ name, eg, example.com.

This is what I have done so far, but I’m afraid it might not be the most elegant, safe, and efficient way to do it.

First, I made sure Apache’s DocumentRoot is set to my app’s webroot directory, so I can tell users to point their DNS to my site’s IP.

Now, this is how the routing rules on my routes.php look like:

if (preg_match('/mysite\.com\.?$/', $_SERVER['SERVER_NAME'])){
    // Normal routes when visitors go to my domain
    Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
    Router::connect('/pages/**', array('controller' => 'pages', 'action' => 'display'));

    // Move all other actions to a separate '/app/' area
    Router::connect('/app/:controller/:action/**');
    Router::connect('/app/:controller/**');

    // Handle profile URLs
    Router::connect('/:profile/**', 
        array('controller' => 'profiles', 'action' => 'view'), 
        array('pass' => array('profile'), 'profile' => '[0-9a-zA-Z\-\_]+')
    );
}
else{
    // If visitors come via a URL different to mysite.com, I let 
    // the ProfilesController deal with it passing the current SERVER_NAME 
    // as a param to the 'view' action
    Router::connect('/', array(
        'controller' => 'profiles', 
        'action' => 'view', 
        $_SERVER['SERVER_NAME'], // 'url' param
        true // 'customDomain' param
    ));
    Router::redirect('/*', 'http://mysite.com');
}

And this is how the view action on the ProfilesController looks like:

public function view($url = null, $customDomain = false) {
    if ($url){
        // Find the profile by its vanity_url or its custom_domain
        $findOptions = array(
            'conditions' => $customDomain? 
                array('custom_domain' => $url) : 
                array('vanity_url' => $url) 
        );
        if ($profile = $this->Profile->find('first', $findOptions)) {
            $this->set('profile', $profile);
        }
    }
    else throw new NotFoundException(__('Invalid profile'));
}

What problems could I face with this approach?

Also, does anyone know why Bandcamp asks users to create a CNAME instead of an A record to set up a subdomain? Am I missing something I should consider here?

Edit Somebody helped me figure that last bit out: It seems you can’t easily use an CNAME record to point a naked domain to another. The main question is still open.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:02:56+00:00Added an answer on June 7, 2026 at 1:02 pm

    I guess there’s no better way 😛

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, I have a CodeIgniter site that registers users through this url: http://website.com/user/register/1 Unfortunately,
I have a fairly simple site which allow users to connect via facebook. I
My website has public-facing profiles. Users may have 145x145 profile images that are displayed
I have a site where users can log in and check on outstanding support
I currently have a web site where users can select a custom theme. After
I have a section of my site where users can add addresses to their
I have created a page on my site where users can post directly to
Let's say I have a site where Users can add Entries through admin panel.
I have a page on my site that lets users respond to invites by
I have a site where users can enter their profile and password-protect certain details.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.