Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
simple way to get a dynamic php page to autogenerate a static html one?
Old 08-27-2008, 07:49 AM simple way to get a dynamic php page to autogenerate a static html one?
Junior Talker

Posts: 1
Name: Daniel
Trades: 0
well... my title pretty much says it all,

is there a way to do this?

so if i have a php /mysql driven site, can i auto create pages into html for better search engine listings...?
Umfanekiso is offline
Reply With Quote
View Public Profile Visit Umfanekiso's homepage!
 
 
Register now for full access!
Old 08-27-2008, 07:50 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
When the page gets sent to the browser IT IS STATIC HTML.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-27-2008, 08:58 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
Experienced Talker

Posts: 33
Name: Toby Osbourn
Trades: 0
Maybe he means instead of having something like.

article.php?a=12345

having

/article/Article_title.html

There are ways of doing this (blogs and message boards have mods to allow this) but it would be a fairly large undertaking.
tosbourn is offline
Reply With Quote
View Public Profile
 
Old 08-27-2008, 09:03 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
PHP Code:
ob_start();
print 
'blah blah blah';
$html=ob_get_clean();
file_put_contents('file.html',$html); 
And so, you have generated a page, and saved the result to an html file
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 08-27-2008, 11:59 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
Junior Talker

Posts: 2
Name: David
Trades: 0
Quote:
Originally Posted by tosbourn View Post
Maybe he means instead of having something like.

article.php?a=12345

having

/article/Article_title.html

There are ways of doing this (blogs and message boards have mods to allow this) but it would be a fairly large undertaking.
once you get the hang of it, it is really rather easy.

if your running an Apache server you will need mod_rewrite installed and configured.

after that you just edit your .htaccess file to contain something like this

Code:
1: RewriteEngine on
2: RewriteRule ^article/([^/\.]+)/?$ viewarticle.php?id=$1 [L]
3: RewriteRule ^section/([0-9]+)/?$ viewsection.php?id=$1 [L]
4: RewriteRule ^section/([a-z]+)/?$ viewsection.php?id=$1 [L]
Line one tells the site to use mod_rewrite
Line two tells the serv that if it gets something like www.yoursite.com/article/42 that its the same thing as if you typed www.yoursite.com/viewarticle.php?id=42

line two accepts just about everything
line three will only accept a string of numbers
and line four will only accept a string of letters

keep in mind that the [L] must be at the end of each line

do a google search for mod_rewrite it will go into much more depth and explain how to write the rewrite rules in much greater detail
DBunting is offline
Reply With Quote
View Public Profile
 
Old 08-28-2008, 04:52 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Quote:
Originally Posted by chrishirst View Post
When the page gets sent to the browser IT IS STATIC HTML.
The difference exists. When you have physical html file the webserver can handle if-modified-since, send date and content-length headers and so on. This will help the webserver to behave correctly from the search engine's point of view. In absolutely most cases people who use dynamic output do not bother with handling if-modified-since and sending date and content-length.

Also serving static files is usually hundreds times faster.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-28-2008, 05:37 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
This will help the webserver to behave correctly from the search engine's point of view
Assuming of course that search engines actually use those headers.

Quote:
Also serving static files is usually hundreds times faster.
Hardly hundreds of times faster, a few nanoseconds maybe, or a few microseconds if your code has to wait for a DB server response for several queries. If your "dynamic" pages are hundreds of times slower you have a MUCH bigger problem.

Oh and BTW

Quote:
so if i have a php /mysql driven site, can i auto create pages into html for better search engine listings...?
It will make absolutely no difference at all!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-28-2008, 05:44 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Hardly hundreds of times faster, a few nanoseconds maybe, or a few microseconds if your code has to wait for a DB server response for several queries. If your "dynamic" pages are hundreds of times slower you have a MUCH bigger problem.
My website serves 350k pageviews daily. On local machine (to exclude network lags) ab shows 110 requests per second (-n 100 -c 10) on dynamic page. On static page this number is about 2.5k. I made a mistake with hundreds of times, but we can talk about tens times difference.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-28-2008, 05:51 AM Re: simple way to get a dynamic php page to autogenerate a static html one?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Requests per second is a different thing entirely to serving out the pages.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to simple way to get a dynamic php page to autogenerate a static html one?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.48273 seconds with 12 queries