By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,638 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

require("common/latest.php") across multiple websites

P: n/a
I've set up the following using an Alias in Apache...

Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/"
<Directory "C:/Apache/htdocs/common/docs/php">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

It works well for HTML, all sites have access to the information.
I want to extend that to PHP require() and include() functions,
however the following maps out to an incorrect folder. Okay,
that's fine. My questions include, does PHP provide something
that maps out to the Apache Alias directive?

The common folder currently sits up two folders (../..) to the
VirtualHost folders. I realize that possibly a PHP "include_path"
directive could work. So the next question, anyone know of
another way to accomplish this?

Thanks.

Jim Carlock
Post replies to the newsgroup.
Jan 20 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jim Carlock wrote:
I've set up the following using an Alias in Apache...

Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/"
<Directory "C:/Apache/htdocs/common/docs/php">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

It works well for HTML, all sites have access to the information.
I want to extend that to PHP require() and include() functions,
however the following maps out to an incorrect folder. Okay,
that's fine. My questions include, does PHP provide something
that maps out to the Apache Alias directive?

The common folder currently sits up two folders (../..) to the
VirtualHost folders. I realize that possibly a PHP "include_path"
directive could work. So the next question, anyone know of
another way to accomplish this?

Thanks.

Jim Carlock
Post replies to the newsgroup.


Sorry, Jim, you can't. PHP doesn't go through Apache to access files;
rather it goes straight to the file system itself. include_path is the
only way to handle it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jan 20 '06 #2

P: n/a
Jim Carlock wrote:
I've set up the following using an Alias in Apache...

Alias /phpdocs/ "C:/Apache/htdocs/common/docs/php/"
<Directory "C:/Apache/htdocs/common/docs/php">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

It works well for HTML, all sites have access to the information.
I want to extend that to PHP require() and include() functions,
however the following maps out to an incorrect folder. Okay,
that's fine. My questions include, does PHP provide something
that maps out to the Apache Alias directive?


http://fi.php.net/apache-lookup-uri/

Jan 20 '06 #3

P: n/a
Jim Carlock asked:
Does PHP provide something that maps out to the Apache
Alias directive?
"Chung Leong" <ch***********@hotmail.com> answered: http://fi.php.net/apache-lookup-uri/


Thank you, Chung Leong. Excellent.

The apache_lookup_uri() works quite well. It even works when
a filename is supplied and appends the filename to the mapping.

Alias /news/ "C:/Apache/htdocs/common/news/"
<Directory "C:/Apache/htdocs/common/news">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<?php
// -- START THIS WORKS
// The topic.htm is not part of the Apache Alias above,
// but apache_lookup_uri() works nicely and accepts it
// and returns it as part of the fully qualified pathname to
// the file.
//
$info = apache_lookup_uri('/news/latest.php');
// print_r($info);
$latesttopic = $info->filename;
require($latesttopic);
//
// -- END THIS WORKS
?>

What's it good for? It offers a great way to provide a common
source of news on multiple websites. I like it. Only one place
to change the news and all sites that display the content get the
update. Look out cbsnews and msnbc! <g>

Now... time to figure a way to provide a way for a subdomain
to access the parent domains include files... without using a php
include in httpd.conf... hmmm. I'm going to get back to figuring
out how to do this with Apache.

Thank you very much, Chung Leong.

Thanks to Jerry Stuckle as well for your time and attempt.

Hope this helps.

Jim Carlock
Post replies to the newsgroup.
Jan 21 '06 #4

P: n/a
Another question...

Using the following code,

<?php require("/common/latest.php"); ?>

Is there a way to detect which page "required" latest.php ?

For instance...

Domain1, homepage (domain1.com/index.php) and
(domain1.com/talks/php/index.php) both employ ...
<?php require("/common/latest.php"); ?>

Domain2, provides similar multiple pages accessing the same
content by requiring...
<?php require("/common/latest.php"); ?>

Is there a php function that detections the name of the calling
page? And is there another way to do this? I'm working with
something along the lines of...

<?php require("/common/latest.php?rp=domain1.com/index.php"); ?>

Any other suggestions or a PHP server variable to detect the
name of the caller (calling page)?

Thanks.

Jim Carlock
Post replies to the newsgroup.
Jan 26 '06 #5

P: n/a
Jim Carlock wrote:
Another question...

Using the following code,

<?php require("/common/latest.php"); ?>

Is there a way to detect which page "required" latest.php ?

For instance...

Domain1, homepage (domain1.com/index.php) and
(domain1.com/talks/php/index.php) both employ ...
<?php require("/common/latest.php"); ?>

Domain2, provides similar multiple pages accessing the same
content by requiring...
<?php require("/common/latest.php"); ?>

Is there a php function that detections the name of the calling
page? And is there another way to do this? I'm working with
something along the lines of...

<?php require("/common/latest.php?rp=domain1.com/index.php"); ?>

Any other suggestions or a PHP server variable to detect the
name of the caller (calling page)?

Thanks.

Jim Carlock
Post replies to the newsgroup.


Yes. See http://fi.php.net/debug-back-trace/ for details.

Jan 26 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.