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

  • SEARCH
  • Home
  • 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 9047903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:01:03+00:00 2026-06-16T12:01:03+00:00

I have written a basic web app in php and MySQL that uses query

  • 0

I have written a basic web app in php and MySQL that uses query strings to look up various information. For example: xxxxxxx.com/?profile=1245

Very basic, first time developer type of web app.

I want to create different accounts that will each have their own sets of data. I want to differentiate these accounts by using subdomains. For example: username.xxxxxxxx.com?profile=4527

I have a catchall set up in my Apache config to divert all subdomains to my main domain and then I can pull that subdomain out using php like so:

<?php list( $username ) = explode( ".", $_SERVER[ "HTTP_HOST" ] ); ?>

Now, HERE’S MY QUESTION:

It seems to me (I’m fairly new to all of this) that performing a string based search for every query I need to do on every page is going to be slow and inefficient. For instance, having to look up SELECT * WHERE username = sampleuser AND profile = 2745

But is that true? What would be the most efficient way? How do web apps that use subdomains normally handle this sort of thing?

Thank you all so much in advance.

  • 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-16T12:01:04+00:00Added an answer on June 16, 2026 at 12:01 pm

    “How do web apps that use subdomains normally handle this sort of thing?”

    Usually each subdomain is mapped in the web engine(apache/IIS) using something like rewrite module, to a specific IP address or a specific root. So blog.* subdomain might point to the root of the WordPress app.

    In your case, that sounds like it wouldn’t apply unless you have a different set of pages for each user. I.e. if they all have a “Account Details” page, and only the data is different, then the only place the subdomain would come into play is with queries, or URLs you generate.

    In your case, you have what are conceptually dynamic routes. Usually you would just query a table to determine what content to serve. In your case it’s not so much content as just data. Sometimes the routes are cached globally in memory using a data structure that is well organized for lookups, in your case lookups via the username that give you back the primary key of the users table. Then without querying the user’s table, you have your filter criteria for data that references that user via a foreign key. So if the navigate to the “Likes” page, you can “Select * From Likes Where UserKey = $userKeyFromLookup”. You would want to choose an in memory data structure for lookups that allows O(1) lookups. I.e. constant time lookups.

    It seems to me (I’m fairly new to all of this) that performing a
    string based search for every query I need to do on every page is
    going to be slow and inefficient. For instance, having to look up
    SELECT * WHERE username = sampleuser AND profile = 2745

    Is profile ID unique to each user? If so, then you don’t need username in the query. The profile ID alone would give you a unique response. If someone visits username.. without a profile ID, then first thing you do is grab the profileID then redirect to the same page but now with that parameter in the URL so that all other navigation is done in the context of that profileID.

    I agree with Stony though, I think you will find quarks with having dynamic subdomains. I would put the username in the URL instead.

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

Sidebar

Related Questions

I have written a basic Windows Form app in C# that has an embedded
I have a basic web application written in Java, running on a tomcat on
I have written a REST web service with Jersey Server (that totally rocks !).
I have a web-site written in ColdFusion that contains both the usual interactive web
I am experimenting with Java Web Start. I have just written a basic JApplet
I have written an ASP.NET web page with C# behind that runs an existing
I have a web application, written in PHP, where we have a couple of
I have a ASP .Net web appliaction written in Visual Basic .Net running on
I have a basic web app in place: it has a registration page, a
I have a web app that needs both functionality and performance tested, and part

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.