PDA

View Full Version : How to build portable site?


stefd
02-25-2001, 10:03 AM
Hi,

I am just beginning to transfer my files from another host to HostRocket.

In all my pages, I include a php file, but now of course the path has to be changed in all the files to make everything work again.

Is there a way to prevent that and make my files more portable from one host to another?

I thought I could rely on DOCUMENT_ROOT to at least get a base path, but here on hostrocket it contains "/usr/local/apache/htdocs/"... (on my previous host, it pointed to my personal home directory).

I would be very interested on hearing from experienced people about stategies, ideas and tips about that problem.

Thanks!
--
Stephane

JordanTLClive
02-25-2001, 05:44 PM
maybe try storing the location in MySQL and then you could do a query to find the location in all of your files, if course you probably have the information to make a connection within the include, but hey its an idea!

sylow
02-25-2001, 05:57 PM
search the net about using .htaccess
you should add a line like
php_value include_path "/home/sylow"

and then you can use include file like
include("blabla.php");

you should check it out I am not sure how it will work

petesmc
02-25-2001, 08:21 PM
Hi,

http://www.codingclick.com/article.php?aid=3

BTW, there are other variables you can uses to get the info. Just lookup in php.net/manual or here for SSI:

http://www.codingclick.com/article.php?aid=2

Peter

richmedium
02-27-2001, 01:30 AM
Well, your coding is obviously out of whack when it comes to positions of your files in the filesystem. You should always take the root directory of your web application as a starting point. Say you have the following structure:

webapp (contains db-vars.php)
webapp/css (contains default.js)
webapp/profiles (contains index.php that needs db-vars.php)

so you code the webapp/profiles/index.php like so

<?
include (../db-vars.php);
?>

or you need to include default.css you do

<?
include (../css/default.js)
?>

this way no matter where you go it will always work, provided you keep the structure static.