Hey everyone,
I’m working on a multi-tenant eCommerce platform (nabisalay.com) where users can create their own stores.
Users get a store handle like: nabisalay.com/@storehandle
I want to let them connect their own custom domains (e.g., mystore.com
).
I’ve added a middleware that checks the requested domain and maps it to the associated store:
public function handle(Request $request, Closure $next): Response
{
$domain = $request->getHost(); // Get the current domain
// Check if the domain exists in user settings
$userSetting = UserSetting::where('custom_domain', $domain)->first();
if ($userSetting) {
// Get the associated username
$username = $userSetting->user->username;
// Merge the username into the request
$request->merge(['username' => $username]);
}
return $next($request);
}
I added the following DNS records:
CNAME www 0 nabisalay.com 300
A @ 0 89.117.27.88 300
CAA @ 0 0 issuewild "letsencrypt.org" 14400
CAA @ 0 0 issue "letsencrypt.org" 14400
CAA @ 0 0 issuewild "pki.goog" 14400
CAA @ 0 0 issue "pki.goog" 14400
CAA @ 0 0 issuewild "digicert.com" 14400
CAA @ 0 0 issue "digicert.com" 14400
CAA @ 0 0 issuewild "sectigo.com" 14400
CAA @ 0 0 issue "sectigo.com" 14400
CAA @ 0 0 issuewild "globalsign.com" 14400
CAA @ 0 0 issue "globalsign.com" 14400
CAA @ 0 0 issuewild "comodoca.com" 14400
CAA @ 0 0 issue "comodoca.com" 14400
I’m on shared hosting using Apache, and this is my .htaccess
file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
nabisalay.shop
) to Shopify, but it doesn’t work with nabisalay.com
.nabisalay.shop sent an invalid response
.Would love any insights or recommendations! 🚀
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community