Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 696 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a city-specific website (city1.example.com, city2.example.com)

#1
How do I make a website with subdomains catering to different cities?

Like `http://philly.example.com`, `http://maine.example.com`, `http://sandiego.example.com`? Most of the site will be the same, like the layout, the wordings, the database, the interface. What will be different will be some city-specific graphics like adding a city name to the logo (eg. Groupon Nyc, Groupon Chicago), changing a hidden variable (city) in the form that searches the database so results will be biased towards the city.

**Question 1**. User visits site. Script determines city from user's IP address then redirect to the correct subdomain.

I can do the detection script, but how do you display almost the same site to each of the different city? I guess you do not duplicate the site 50 times for 50 different cities, handling the changes to every site will be insane!

**Question 2:** Assuming you do not duplicate the site each time for a new city and change the images and text slightly, how do you do the city-specific changes then?

Do you have a list of 50 `case-ifs` or `if-elseif-else` for every city-specific item on the page? I foresee doing this will mess up the code for the entire page!
Reply

#2
Q1) You have the cities in a database and then whatever you want to show, you do by cityid.

Q2) Again, show data by cityid.
Reply

#3
It's fairly simple with a wild-card DNS/web setup.

1. Set your domain's DNS to map `*.example.com` to your server's IP address
2. Set Apache to do wildcard vhost: `<VirtualHost IP:80>ServerAlias *.example.com example.com`
3. In your PHP script, you refer to `$_SERVER['HTTP_HOST']` to figure out which sub-site the user is accessing, and tailor your content from there.
Reply

#4
It really depends on how much of your information is different per city. It seems like you have really three choices.

1. *Separate* databases (exactly the same structure but different data)
2. One database with table called CityBasedContent (with CityId and content and contentkey eg. `SANDIEGO -> logo -> "img/sandiego.gif"`)
3. You *only change few images* maybe some css for colours - ie. not many changes between them. I would just do what @Marc B suggested and/or put css/img in folders based on their cityId. As it would make switching easier.

Pretty much when person loads the page you check where they are - you might want to do "Are you sure" sort of dialog where it asks that they are in fact in the city you have detected.

If you go with option 1, all you do is you change currently used db to city specific db. For option 2 you just setup global cityId, so all queries are made to that specific city.
Reply

#5
To do this you could create two tables.

**Table 1:**

id INT Primary key
city_name VARCHAR 255

**Table 2:**

id INT Primary key
city_id INT Foreign key
page_id INT
page_content TEXT

1. You determine what city the user is from and grab the city ID from table1
2. Select the content related to that city in table 2 using the foreign key from table 1
3. To handle images you could fetch your images based on a strict naming convention (eg. img-brisbane-header.jpg, img-cairns-header.jpg) making a different image for each city.

There are a bunch of different ways of doing it. It depends whether EACH city is going to have different content, or just a select few. Otherwise it will be more technical as you need to determine which content will apply for which city. This would require tweaks to your sql tables.

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through