You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by David Blomstrom <da...@yahoo.com> on 2004/02/16 08:44:45 UTC
[users@httpd] Setting PHP Include Links in htaccess file
I've been using PHP includes on my website. This is
what some of the links looks like:
<?php include ("includes/top.php"); ?>
<?php include ("../includes/top.php"); ?>
<?php include ("../../includes/top.php"); ?>
<?php include ("../../includes/top.php"); ?>
I wanted to replace the ../ sequences with a variable,
so that I could post the exact same link on every
page, and it will work. I received these instructions:
put this in the .htaccess:
PHP:
php_value include_path .;C:/sites/freedomware/includes
You wont even need to use "includes" in the include
call:
PHP:
include ("top.php");
On a *nix based host you'd want to use a colon instead
of a semi-colon after the period wich comes after
"include_path" in the .htaccess file.
So I tried it. I found the htaccess file at
C:/xampp/webdav/htaccess. I opened it with Notepad,
and this is all it said:
AuthType Basic
AuthName "XAMPP with WEBDAV for DREAMWEAVER"
C:/xampprequire valid-user
AuthUserfile C:/xampp/webdav/.htpasswd
I added the line I was given, changing it to this:
AuthType Basic
AuthName "XAMPP with WEBDAV for DREAMWEAVER"
C:/xampprequire valid-user
AuthUserfile C:/xampp/webdav/.htpasswd
php_value include_path .;C:/sites/freedomware/includes
Then I restarted my computer, opened one of my pages
and replaced...
<?php include ("../includes/top.php"); ?>
with...
include ("top.php");
But that didn't work. (When I preview my page, I see
"include ("top.php");" at the top.)
I also tried this:
<?php include ("top.php"); ?>
When I do that, I get this error message:
Warning: main(top.php): failed to open stream: No such
file or directory in
C:\sites\freedomware\world\index.php on line 21
Warning: main(): Failed opening 'top.php' for
inclusion (include_path='.;C:\xampp\php\pear\') in
C:\sites\freedomware\world\index.php on line 21
However, the rest of the page previews fine. But when
I change it to this...
PHP:
<?php includes ("top.php"); ?>
...the entire page goes blank, except for this error
message:
Fatal error: Call to undefined function: includes() in
C:\sites\freedomware\world\index.php on line 21
Can anyone tell me if I'm on the right track, and what
I have to do to make this work?
I also have a question regarding these instructions:
"On a *nix based host you'd want to use a colon
instead of a semi-colon after the period wich comes
after "include_path" in the .htaccess file."
If I'm working on Windows, but my websites are hosted
on a Linux server, can I make TWO htaccess files - one
that lets me preview my pages on my computer, and a
second htaccess that replaces...
php_value include_path .;C:/sites/freedomware/includes
with...
php_value include_path .:C:/sites/freedomware/includes
Then can I publish this second htaccess file to the
Internet so my online websites will work?
Finally, if I want to do this with several websites,
would I just add multiple lines to my htaccess file,
like this?:
AuthType Basic
AuthName "XAMPP with WEBDAV for DREAMWEAVER"
C:/xampprequire valid-user
AuthUserfile C:/xampp/webdav/.htpasswd
php_value include_path .;C:/sites/freedomware/includes
php_value include_path .;C:/sites/animals/includes
php_value include_path .;C:/sites/geobop/includes
php_value include_path .;C:/sites/geoworld/includes
Thanks.
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org