Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nabisalay's avatar

Custom Domain Integration for Stores on nabisalay.com Not Working (Shared Hosting, Apache)

Hey everyone,

I’m working on a multi-tenant eCommerce platform (nabisalay.com) where users can create their own stores.

How It Works By Default

  • Users get a store handle like: nabisalay.com/@storehandle

  • I want to let them connect their own custom domains (e.g., mystore.com).

What I’ve Implemented So Far

Middleware for Domain Mapping

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);
}

DNS Records I’ve Set Up

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

.htaccess Configuration (Apache, Shared Hosting)

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>

The Issue

  • I successfully connected a custom domain (nabisalay.shop) to Shopify, but it doesn’t work with nabisalay.com.
  • When visiting nabisalay.shop it show this error nabisalay.shop sent an invalid response.

Questions I Need Help With

  • What might be causing the domain to work with Shopify but not with my platform?

Would love any insights or recommendations! 🚀

1 like
8 replies
vincent15000's avatar

Please read once again you post, once you say that nabisalay.shop works, once you say that it doesn't work.

Then you are talking about shopify, I don't understand why. Are you using shopify ?

Can you give a concrete example of what happens, the error you get and what you are expecting for your application.

1 like
martinbean's avatar

@vincent15000 Yeah, I had trouble following the post and trying to work out exactly what was being asked by the OP 😅

Nabisalay's avatar

Hey @vincent15000 & @martinbean,

I appreciate your patience! Let me clarify my issue again.

I am not using Shopify—I only pointed my custom domain (nabisalay.shop) to Shopify temporarily to confirm that the domain works. It connected successfully.

The actual issue: When I point nabisalay.shop to my own platform (nabisalay.com), it doesn’t work.

Expected behavior: Visiting nabisalay.shop should load the corresponding store hosted on nabisalay.com.

Actual behavior: Instead, I get a browser error:

“nabisalay.shop sent an invalid response.”

What could be causing this issue? Any insights would be greatly appreciated!

1 like
Nabisalay's avatar

@vincent15000 & @martinbean Please let me know if you need any additional details or clarification—I’d be happy to provide more context.

Any help on this would be greatly appreciated!

1 like
martinbean's avatar

@nabisalay If this is shared hosting, then I imagine your hosting package is going to have a “primary” domain associated with, and the host will only accept requests for that hostname.

Your host is not going to allow requests for any domain to hit the server, because that server will have multiple customers’ websites (since it’s shared hosting). How does the host know to pass the request to your application? What if another customer on the same server had a “multi-tenant” platform that allowed customers to attach custom domains? How is the host supposed to know which customer’s application to deliver the request to? Answer: they don‘t, because it’s a security risk.

Also consider this scenario. You have a website with the domain goodwebsite.com, and there is another customer on the same server (badwebsite.com). You change your domain name to betterwebsite.com. What happens to requests for goodwebsite.com? If badwebsite.com set up a “multi-tenant” platform and accepted any and all requests to the server, then they’d be able to “take over” goodwebsite.com, steal traffic, run phishing campaigns, etc.

So, you either need to set up an alias domain in your shared hosting account for the customer domains you wish to support (and so that the host directs requests for those domains to your account). Or you need to use something better than shared hosting.

2 likes
Nabisalay's avatar

@martinbean then what should I do ? I just want to allow users to link their custom domain with the store they have on nabisalay.com just like Shopify does

1 like
martinbean's avatar

then what should I do ?

@Nabisalay I already told you want to do:

So, you either need to set up an alias domain in your shared hosting account for the customer domains you wish to support (and so that the host directs requests for those domains to your account). Or you need to use something better than shared hosting.

Your host is not going to accept requests for any hostname and pass them to your application. You’re on a shared host. It’s shared with other people. Again, what if someone else had a multi-tenant platform on the same server? How does the host know which customer and which website to send the request to for handling?

2 likes
VadimPolh's avatar

we need to configure Apache to accept all domains:

  1. On shared hosting, this is usually done by adding domains as "Addon Domain" or "Parked Domain" in the control panel

  2. If you have access to Apache configuration, you can create a wildcard virtual host

  3. Solve the SSL certificate issue The main reason for the "invalid response" error is the lack of an SSL certificate for the nabisalay.shop domain On shared hosting, activate Let's Encrypt for each custom domain through the control panel Many hosting providers offer AutoSSL, which automatically issues certificates

Modify .htaccess

# Important: first process requests without HTTPS only if SSL is available
RewriteCond %{HTTPS} off
# You may need a condition to check the domain here
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Other rules ...

# Direct all requests to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
1 like

Please or to participate in this conversation.