Forum Moderators: phranque
18,000 entrees in a database.
say 10 entrees to be listed per page.
so, 1800 pages.
I don't want to hand code these naturally if i can help it.
(this is for my pet sports project and I can only work on it at night)
is there a way to have mod rewrite create static .html pages based on a couple of fields in the database, AND handle creating the links in the pages so they look static?
I have spent some time looking at mod rewrite, but I am not sure this will do what I want. :P
Should I just make a php template and get to work, or do you think mod rewrite will be my savior?
(not looking for just answers, opinions on whether this is worth pursuing would be appreciated too :)
mod_rewrite functions as an incoming-URL to filename translator (internal rewrite mode), or as an incoming-URL to URL translator (external redirect mode).
So yes, you'll have to change the links that are output as HTML on your pages. When someone clicks on one of those 'static' links, mod_rewrite can intercept that URL and rewrite it to your script, moving part of the requested URL-path into the script URL's query string if desired.
Jim
Ok, so say I create an index.php, and that within the page, I make a proper link to a static page
ie: <a href="product2135.php">
If I understand you correctly, mod rewrite could take my call of product2135.php (which doesn't actually exist), evaluate it as index.php?product=2135 and display a page that would appear to SE spiders and visitors AS product2135.php?
Take a look through some of the previous threads here for implementation details. Usually, you can do this using preg_replace in the php file, thus requiring no change to your database. The preg_replaced friendly URL is then "published" on the page, so this is what the world sees. Then, when that friendly URL is requested from your server, mod_rewrite changes it back into the form your script needs, and none the wiser. Preg_replace and mod_rewrite both use regular expressions, and what preg_replace does to the orignal URL, mod_rewrite reverses. SO the outside world sees a friendly URL, and the internal operation of your script is unchanged.
Try using a Google site search of WebmasterWorld for "rewrite static URL dynamic" and similar phrases - there are a lot of threads on the subject.
Jim
Say i have a folder off the root called widget
and say what i am looking for is to call:
[domain.com...]
as have it parsed, etc,etc as:
[domain.com...]
Here's what I have:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /widget
RewriteRule /(.*)/(.*)\.php$ /index.php?$category=$1\&$startdisplay=$2
And yet, no happiness.
I plan to keep trying to see where my mistake is, but if anyone would like to learn me....i'd appreciate it :)
Options +FollowSymLinks
RewriteEngine on
RewriteBase /posters
RewriteRule ^(.*)/(.*)\.php$ index.php?category=$1\&displaypage=$2 [L]
I simply cannot believe the power this has.
I kind of grasped it yesterday. Today I am in shock.
almost 2000 static pages ready for the search engines.
It took 2 files, taking just over 22k in harddrive space (totally ignoring the database size of course)
Amazing. Simply Amazing. I plan on reworking several major section of our websites using this technology :)
RewriteRule ^(.*)/([^/.]+)\.php$ index.php?category=$1&displaypage=$2 [L]
Jim