Jump to content

auto generate hundreds of pages


kabs

Recommended Posts

I have a php website.  There is a dynamic page that works like this:

 

www.mywebsite/carpage.php?car_id=1

www.mywebsite/carpage.php?car_id=2

www.mywebsite/carpage.php?car_id=3

....etc. to car_id=500

 

The variable (car_id=1, 2, 3, ...500) is passed from the url to the sql query in the page code.  Let's say 1= Ford Pickup, 2=Ford Focus, 3=Dodge Durango.

 

What I want to do is create a bunch of pages like this:

 

www.mywebsite/ford_pickup.php

www.mywebsite/ford_focus.php

www.mywebsite/dodge_durango.php

 

In these pages, I'd like the variable to be hard-coded into the sql query ideally.  if I still have to have the vairable in the url, that would be the end of the world, but ideally I can remove all the variable strings from the url.

 

How I can do this now:  Open a page in Dreamweaver, edit the code to hard-code the correct car_id in the sql query.  Save AS the file as ford_pickup.php.  Repeat 500 times.

 

I figure there is something out there to help me with this, but all searches for Auto Generate Webpages and similiar are yielding no-so-good results.

 

Any thoughts on how to get on the right track here much appreciated!!

Link to comment
https://forums.phpfreaks.com/topic/75302-auto-generate-hundreds-of-pages/
Share on other sites

As has been said, you really don't want to generate hundreds of pages.  The ideal solution for this situation is to use ModRewrite.  I'd recommend adding another directory to your pathname, to keep the .htaccess simple.  Something along the lines of:

http://www.carwebsite.com/model/ford focus

 

Then in the /model/ folder put an .htaccess file with something like this...

Options -Indexes
RewriteEngine on

RewriteRule ^(.*)$ /model/$1/ [R,NC]
RewriteRule ^(.*)/$ /model/carpage.php?model=$1 [NC]

 

You would still do your processing in /model/carpage.php, pulling records by model.

Be sure to do plenty of data checking.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.