homepage Welcome to WebmasterWorld Guest from 54.166.105.24
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Making PHP pages SE friendly
Needing advice on some code...
stuart




msg:1274798
 9:50 am on Apr 24, 2002 (gmt 0)

Being a total novice to server side scripting (and working with someone else to build a mysql/php set up), I've found the following piece of code which apparently allows you to keep the page extensions as html, but forces the webserver to treat html pages as php pages without any variables passing through the URL (eg page.html?a=b&c=a+b):

AddType application/x-httpd-php .html .htm .php

Does anyone have any experience with this, if so does it work or are there some pitfalls. I was going to produce a static html site from our database but use the php in the background for functionality; but if this avoids the need to do that it maybe useful (i think!). Any advice would be much appreciated. TIA. Stuart.

 

sugarkane




msg:1274799
 12:49 pm on Apr 24, 2002 (gmt 0)

I've used this on some sites without problems, but it's worth bearing in mind that by default PHP pages will include a server header of X_Powered_by_php in every page, identifying it as a dynamic page.

Whether this has any effect on the way search engines treat the page I don't know - I've not seen any yet.

Generally I produce static pages as you were considering, just to be on the safe side - would it be a major task to do that on your site?

stuart




msg:1274800
 2:04 pm on Apr 24, 2002 (gmt 0)

Thanks sugarkane, I guess we'll go the static html site/php functionality route to be safe, which was the initial idea.

I know its a never ending question but whilst i'm here and because we're so new too this can i ask if you have any general tips or know any major pitfalls to this sort of set up?

We currently produce static pages offline using templates and a java pagebuilder, but whats the best set up if we have a mysql database online (sychronised in parts offline).

How longs a piece of string, right!?!

sugarkane




msg:1274801
 2:33 pm on Apr 24, 2002 (gmt 0)

> How longs a piece of string, right!?!

Hehe, that's about right ;)

Much depends on the design of your site. In my case I build the site in Perl or PHP, using modules / includes to provide the templates.

Rather than using a single dynamic 'display' page that pulls data from a database (eg display.php?product=1), I use individual files that act as a wrapper for the display routines - eg file product1.php would simply consist of:

<?
$product=1;
include("display.php");
?>

All internal navigation points to these wrapper pages rather than the actual pages that generate the dynamic content, so there's a fully spiderable site structure there that doesn't rely on query strings. Whether this structure is the main navigation of the site or done through building a site map is up to you.

At this point you could use the AddType 'trick' to name the pages as .html, but I use a Perl script to spider the site and save the spidered pages as static html, adjusting the internal links from .php to .html, which effectively generates a static 'mirror' of the site. Once functionality is required (eg 'add to cart'), the original PHP pages take over.

All this is done on the development server, and I then transfer the whole lot to the production server.

I'm sure there are many other approaches but I've found this one to be the most effective for me.

stuart




msg:1274802
 2:43 pm on Apr 24, 2002 (gmt 0)

Thats great sugarkane, thanks for taking the time to reply, its early stages for us at the moment so its really helpful to hear how people are doing these things. Thanks very much.

jatar_k




msg:1274803
 3:40 pm on Apr 24, 2002 (gmt 0)

I use php parsed in the .html extension and have had no problems. I always use a modular setup that doesn't use a templated page just includes headers, footers, menus etc so I can keep maintenance to a minimum. I also do a similar setup to sugarkane, staying away from query strings all together and passing vars inside the page or posting them if necessary.

I didn't realize the header info, thanks sugarkane, the thought actually never crossed my mind.

sugarkane




msg:1274804
 3:51 pm on Apr 24, 2002 (gmt 0)

Apparently the x-header can be got rid of via a compile option in PHP, but that's probably not an option for most of us. Does anyone know of a different way? An Apache config option possibly?

knight




msg:1274805
 3:38 am on Apr 25, 2002 (gmt 0)

i use php with the .html on all my pages. There is a way to get rid of the php header, you could probably do it with the .htaccess file. or if you had access the to php config file you could change the php mode to invisible. (I think that would work)

as far as i know search engines dont care about the php in a pages, and there are many more widely used methods of finding if a page was dynamically created. This goes back to the http specification, if you are interested in knowing I will go on.

If you are going to be using php in all your pages any ways, the only problem I can see with the .html is deleting or causing an error in your .htaccess file could cause a lot of damage, including revealing the pass and username for your database. I know the odds are slim if you are using a production server but it could happen. There are ways around this if you would like to hear about it.

I donít want to keep you too long,

Brendan

stuart




msg:1274806
 10:02 am on Apr 25, 2002 (gmt 0)

Thanks Brendon, please do go on with both points though if you don't mind, about the http specification and protecting the .htaccess file; at this stage all practical experience is really helpful. TIA. Stuart.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved