HamidHossain
asked on
Auto Include a file
Hi,
Is there any way to inforce including a file into any php file user visits under my subfolder?
- root
|
--- subfolder
|
--- config.php
|
--- page1.php
|
--- page2.php
for example, I want to include config.php file if user visited page1.php or page2.php files. This inclusion must be automatic. I am not looking for using include() or require() etc... I am looking for some .htaccess command or something in this level.
Regards,
Hamid
Is there any way to inforce including a file into any php file user visits under my subfolder?
- root
|
--- subfolder
|
--- config.php
|
--- page1.php
|
--- page2.php
for example, I want to include config.php file if user visited page1.php or page2.php files. This inclusion must be automatic. I am not looking for using include() or require() etc... I am looking for some .htaccess command or something in this level.
Regards,
Hamid
If your server supports it, you could create a .htaccess file in the subfolder that contains:
php_value auto_prepend_file "/full/path/to/root/subfol der/config .php"
php_value auto_prepend_file "/full/path/to/root/subfol
so it is possible using a htaccess.. was wondering... :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Split: Codejunkie, benbalbo
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
- Neester -
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Split: Codejunkie, benbalbo
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
- Neester -
EE Cleanup Volunteer
What you could do is use a script like below as index.php. That way the urls you use could stay almost the same and request the seperate scripts like this. Unfortunately, if its an existsing project, it might mean alot of adjusting links/redirects etc.
the original requests were:
page1.php?var1=2
page2.php?var3=4
that would become:
index.php?var1=2&src=page1
index.php?var3=4&src=page2
<?
include 'config.php';
include $_REQUEST['src'] . '.php'; //todo: you should encode the src variable to avoids hacks
?>