hi
I have a script which
- queries the database for records in cities
what I want to do is:
- create unique folders for each city on the server
- create a index.html page for each folder
so for example:
if I had 5 citys (A,B,C,D,E)
Each city had 10 records.
I would have 5 folders named A,B,C,D each with its own index.html file and 10 results
How can I achieve the snapshot of results?
create folders and capture results in html file
Moderator: General Moderators
Re: create folders and capture results in html file
The most common way would to use url rewriting.
Since you have all of the data in the database,
Take this example.
.htaccess file
city.php
Then go to yourserver/city/cityname and you will see `cityname` echoed. Using this you can then select the data from the database instead of creating folders and files.
Since you have all of the data in the database,
Take this example.
.htaccess file
Code: Select all
RewriteEngine On
RewriteRule ^city/([^/\.]+)/?$ city.php?city=$1 [L] #Route everything after /city/ that does not have a period
Code: Select all
<?php
$City = !empty($_GET['city'])? $_GET['city'] : NULL;
echo $City;
// Get Data from database..- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: create folders and capture results in html file
Do you really want to create that many folders and files? What happens after 5,000 users have run this script? How do you maintain that?
Re: create folders and capture results in html file
Just too confirm:
step 1: create a folder in the root /city
step 2: create the .htaccess file in the root
step 3: in the /city folder create the file city.php with my query and record results, and page layout. I believe this page will get displayed when a city is searched
What will happen. If users are searching on "aber" and then "aberd" - will this create two folders?
The reason for doing this is so we can get indexed better on google. I have noticed a lot of sites indexed have folder structures for cities i.e. they have folders like birmingham/index.html, leeds/index.html, manchester/index.html. If you have any other idea of doing this I would be interested.
Thanks
step 1: create a folder in the root /city
step 2: create the .htaccess file in the root
step 3: in the /city folder create the file city.php with my query and record results, and page layout. I believe this page will get displayed when a city is searched
What will happen. If users are searching on "aber" and then "aberd" - will this create two folders?
The reason for doing this is so we can get indexed better on google. I have noticed a lot of sites indexed have folder structures for cities i.e. they have folders like birmingham/index.html, leeds/index.html, manchester/index.html. If you have any other idea of doing this I would be interested.
Thanks
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: create folders and capture results in html file
You do not need to literally make files and directories for each request. Simple URL rewriting can handle that for you (and I think it was already suggested in this thread). If you are on apache you can use mod_rewrite to make some URL rewriting rules so that all requests for http://mysite.com/city/aber/ will make to index.php?q=city&term=aber.
Re: create folders and capture results in html file
Since the requests are not as folders on the server, when the search engine spider crawls the site it will not find these folders and not index them
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: create folders and capture results in html file
The rewrite rules will handle that for you. That is how things are done. Really. Imagine a high traffic site that has millions of "pages" of data. Do you honestly think they make an actual hypertext page for each one?