On our live site, coded by other developers, we have a globals file on the root. It's auto-prepended to each requested PHP file. Great.
We're now trying to make a development server to mirror our live, for internal purposes. I'm looking in their global config for apache, and I see this:
php_value auto_prepend_file /home/site/SITE/globals.php
However, while making an .htaccess file, I try to call the file using the direct URL, (based on the root of the server) and I get this error:
Fatal error: Unknown: Failed opening required 'opt/lampp/htdocs/globals.php'
(include_path='.:/opt/lampp/htdocs/site/SITE/include') in Unknown on line 0
It seems as though it's trying to use the include path for an auto-prepend. I can confirm that if I put just globals.php, it will work in the index and files on the root of the server. Do you guys have any leads as to what the problem could be?
Replacing our config file with the live one is not an option.
auto_prepend_file is being used when you want to include php file into every php file.
there are two kind of value it can has:
**File name**: in this case you put only file name and php searches according site's document root (or include path).
*Path & file name*: in this case you put file name and the path to file.
so, if their auto_prepend_file has the value /home/site/SITE/globals.php, so php looks in that path! so if you want to add that file into your php files you have to edit that php directive.
Related
I want to include a file using .htaccess, the file is opened on the
Homepage but not in other places like folders.
Here is my code block on .httaccess
php_value auto_prepend_file "Main/API.php"
the error message
Fatal error: Unknown: Failed opening required 'Main/API.php'
In other folders, the string "Main/API.php" means somewhere that can't be reached.
Either place a different .htaccess in those folders, or try using absolute paths (i.e. "/var/www/www.site.com/htdocs/Main/API.php", or "/Main/API.php").
I have installed the plugin 'Advanced Search Plugin Like Facebook Search' of younet and I noticed the error that application/modules/Core/externals/scripts/ynadvsearch.php is not found.
Then I checked the location and the file was there. So I uploaded a test.php file and typed the url in address bar then also I could not access the test.php page. But I am able to access all the js pages on that folder.
I have deleted the htaccess file of external folder. But the issue remains the same.
How can we fix this?
It's a little weird, usually /externals/scripts folder is used only for javascript-files (and all php-files - inside of /controllers folder).
File .htaccess inside of /externals folder contains a rule
<FilesMatch "\.avi|flv|mov|wmv|wma|mp3|mp4|m4a|mkv|swf|pdf|doc|ppt|ico|jpg|jpeg|png|gif|js|css)$">`
It means that *.php files are not allowed for access inside of this folder.
I'm new to Twig and was wondering where I should place the Twig /templates directory.
I'm using composer and placing the /templates in the root directory where the index.php is and it gives me the following error message :
Message: The "/templates" directory does not exist.
File: /home/teo/SERVER/public_html/JSON_FOLDER/JSON2/vendor/twig/twig/lib/Twig/Loader/Filesystem.php
Generally you put it anywhere not within your web root, that's the best practice. But if you have no access anywhere else, then the web root will have to do.
I'm not completely familiar with composer, but you'll probably want to specify a path that is relative to your web directory instead of an absolute directory like you've done already. That error shows that its trying to find a templates path in your server ROOT directory which is almost never going to be where you actually want it. Try just removing the leading slash in your config.
I have my website hosted on 1and1 servers and I want to adjust some settings in a php.ini file. I can create the file and it is being interpreted correctly but only for the immediate directory not for any subdirectories. I would like to not have to copy the php.ini file into every single subdirectory. The only way I have seen to do this from googling is to add the following to the .htaccess file
suPHP_ConfigPath /path/to/htdocs/php.ini
I have an .htaccess file and the different directives I have in there are being interpreted correctly but when I add that line it causes a 500 Internal Server error.
Can anyone suggest what I can do so that the php.ini settings are used in all the subdirectories without having to duplicate the php.ini file into all the subdirectories?
You could create soft links in each folder to your main php.ini. 1and1 disallows many directives in their .htaccess files. 1and1's support site has more information.
The suPHP is evaluated in a .htaccess PerDir context. If you want to have different ini files for different directories then you need to use a separate .htaccess in each relevant directory. By default Apache will use the lowest .htaccess on the request URI's path that it can find. Alternatively if you have a systematic naming convention for the filenames, then you ban place the different suPHP directives in different directives.
I have an .htaccess file in the folder called folder and another file, called form.html in the same folder
When I try to reach the folder (by entering http://blablabla/folder/), it does block the access and I am getting an error 403 but when I enter the exact URL of the file http://blablabla/folder/form.html anf hit enter, I can access the file as easily as if I haven't put any .htaccess file.
Am I doing something wrong?
Am I missing something, should I use something like or
Sorry if the question is really basic...
.htaccess is a container for directives for your apache web server that apply to that directory and below only. What directives have you got in your .htaccess file?
The behaviour you outline above is how apache should behave with no .htaccess folder.
What is it that you are wanting to happen?