1

I have a situation where i have different domains having the A record for my server. So all the domains are pointing to the same laravel server. Now when ever laravel runs i want to get the domain name that sent the request and then change the logo of the website. What is most efficient way of doing this?

I want to keep it light and simple. I just have a few domains so i dont have any issues hardcoding them up to save a db query.

1 Answer 1

1

You can write your code in your BaseController.php and pass some value to your view to show right logo.

For getting domain name you can simple use Laravel method

if (strpos(Request::root(), 'domain1.com') !== false) {
    $domain = 1;
} else if (strpos(Request::root(), 'domain2.com') !== false) {
    $domain = 2;
} else {
    $domain = 3;
}

And as I mentioned above, you can share $domain with your view.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your answer, i also had something similar in mind. I ended up creating a group route middleware and assigning the logo image (link) to the session. Will it have any issues when scaling the server horizontally?
Will it have any issues when scaling the server horizontally? You have to edit the code again for new domain if you use this approach.
Thankyou for your reply, what i mean is if i was using something like aws beanstalk with autoscaling, does the session maintain itself over all the new servers added automatically?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.