Page 1 of 1

City Specific Website

Posted: Mon Dec 29, 2008 12:39 am
by kalpesh
Hi, I am just trying my site to be city specific for user to select a specific city.
I see lot of sites which are city specific but what I found is two things.
First :- They make pages for every city individually.
Second :- In other sites when i select city in textbox url in page change to something like this.
First it has url like this:http://www.example.com/index.php
After select it has like this : http://www.example.com/Newyork/index.php
The contents are same but it has fetch contents by city.

In second case i think they only rewriting url.
But they are using same page as main index.php or they create page for City which only fetch contents citywise which is found in url.Thats something i didn't understand.


I have in database some tables which has column city.I don't want to change database structure.
I don't want to create new tables for city specific.

So how can i approach to this problem.
What is the optimized solution for this problem?
Please help me
Thanks in advance.

Re: City Specific Website

Posted: Mon Dec 29, 2008 2:54 am
by sergio-pro
Hi

You can make it like this:

Code: Select all

 
    $uri = $_SERVER['REQUEST_URI'];
    //Remove first slash
    if (strpos($uri, "/") === 0) {
        $uri = substr($uri, 1, strlen($uri)-1);
    }
    $split = split("/", $uri);
    if (count($split) > 1) {
        echo "City is: " . $split[0];
        //Fetch city-specific info here 
    } else {
        echo "No city";
        //Fetch general info here
    }