behnampmdg3
8 months ago

Different sub domain per account

Posted 8 months ago by behnampmdg3

Hi;

I am building this small membership portal and the way it works... each course author can build their own course and their users log in and consume the material.

It's in progress and I don't see any major issues however there is one thing I am not sure how to do.

I want to be able to give them specific sub domain. I have seen other sites do it automatically on sign up.

For example:

jeffway.goldmembers.com ben34.goldmembers.com tennishero.goldmembers.com

And so on.

And when someone logs in, everything is through that url. Fore example:

tennishero.goldmembers.com/course-slug tennishero.goldmembers.com/course-slug/modules tennishero.goldmembers.com/course-slug/module-slug/lesson-slut

Of course the code is the same, the "sub-domain" doesn't affect the code. The code works properly with sessions and ids like the blog Jeff shows.

Ideal would be to store the "user_subdomain" in this table.

CREATE TABLE `users` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

What is the best practice?

Thanks

Please sign in or create an account to participate in this conversation.