Forum Moderators: phranque

Message Too Old, No Replies

relative path for auto prepend file?

         

httpwebwitch

6:13 pm on Oct 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



this is my .htaccess command:

php_value auto_prepend_file "header.inc"

this is prepending to pages in the root, like
/index.php
/rootpage.php
etc

but when I request a page in a subdirectory such as /abc/index.php, I get this error:

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

obviously, it's looking for "/abc/header.inc" and it ain't there.

how do I syntax up my .htaccess to always get that included file from the root directory?

i tried

php_value auto_prepend_file "/header.inc"

and it didn't work

httpwebwitch

6:33 pm on Oct 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ha. it wasn't so tricky after all - i just had to use the real file path, eg. C:\web\public_html\etc\etc\header.inc

ignore me

jdMorgan

9:23 pm on Oct 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was going to suggest adding a leading slash to make it "server-relative" instead of "page-relative."

php_value auto_prepend_file [b]"/h[/b]eader.inc"

Jim

httpwebwitch

12:08 am on Oct 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yeah. tried that. didn't work.

jdMorgan

12:28 am on Oct 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, didn't want to follow instructions and ignore you, though...

So duly noted, it requires a full filepath.

Jim

g1smd

11:29 pm on Oct 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Cool. You just gave me a clue as to how to fix a related problem with PHP include files, where I want to make the code portable. I can add an auto-prepend file with a PHP variable in it that defines the include filepath.