SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with the Page generator script

    hello masters

    I am working on a script that will generate about 7-8Millions pages. yes that much !

    The size of the page would be 16 to 20 KB, therefore it might be about 60-70GB so if this is the script that what might be the issues apart from the space on the server ?

    Secondly, the script gathers some keywords and then create pages for each TOWN in each state of the USA. There are about 35000 towns in the database and there are about 200 keywords so far. so the page will be like this :

    town-state-keyword.html

    that is how it will generate millions of pages i.e. 35000 x 200 = 7,000,000.00, is that ok ? or there might be a better way possible. I know that this can also be done via .htaccess (Mod_rewrite) But i need help as I never worked on that and I do not know how to convert the parameters to town - state and keywords for the HTML.

    Please guide !

    Thanks
    zeeshan

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would use modrewrite. I think the major problem with a php script like that would be the script timing out before its finished.

    Give this a try: I'm no expert as mod_rewrite or regex so maybe someone can make my code a little better.

    Code:
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      
        RewriteRule ^/?([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+).html$ /town.php?city=$1&state=$2&keyword=$3
    
    </IfModule>
    This is for the .htaccess. It would send the page to town.php which you would create to get the variables from the url and output the page requested.

  3. #3
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot ! I was thinking for that too.

    But I need to know 1 thing, i will also have a directory where links to those pages will be placed. So should I link my pages using "TOWN-STATE-TEXT.HTML" ? or the link will be "index.php?town=TOWN&state=STATE&text=TEXT

    Please guide

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should use e.g. "TOWN-STATE-TEXT.HTML", in Apache it will be converted according to the mod_rewrite rules.

  5. #5
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I would actually recommend something a little more hierarchical, like State-Town-Keyword.html.

    Even better would be:
    /State/Town/Keyword/

    That way you could also have a page for each state and each town, i.e. the page:
    /State/
    Would have links to all the towns in that state, and the page:
    /State/Town/
    Would have links to all the keywords.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  6. #6
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi

    I am still confused how to set the links to those dynamic urls ?
    like on a page I will have all the stats and that each will have this in their href:

    www.site.com/somepage.php?st=State_name_here

    so should I link this way ? or I should like follow :

    www.site.com/State_name_here.html
    and the MOD REWRITE will take care of the thing its own ?

  7. #7
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi
    Thanks a lot guys I got the solution, I have to put my links as www.site.com/a-b-c.html and the mod thing will take care of it. Thats great !

    Now i want to know another issue:

    Remember, I mentioned that following are the variables to my php script :

    http://www.website.com/index.php?sta...wn=TW&issue=IS

    how to handle this if the user enter only
    www.website.com/index.php?state=ST
    or
    www.website.com/index.php?state=ST&town=TW
    or
    www.website.com/index.php?issue=IS
    or
    www.website.com/index.php?town=TW

    or any other combination of the two ? i want the mod rewrite thing to handle that too. Like there might be cases where there is only state or issue or town ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •