Jump to content

Help with using a .htaccess file, local php.ini, or other


roseuz

Recommended Posts

Hello.  I need to get this solved as soon as possible and have been desperately looking for help, but haven't been able to find any so far. I have a page that's running PHP on a server that's using PHP 4.4.0. As a result, my sessions are not retaining their values when the page is refreshed or code is repeated, as in a loop: You can read more about it here if you like: http://phosphorusandlime.blogspot.com/2006/10/php-session-array-bug-clarified.html

 

The main thing I am trying to accomplish is to turn of the register_globals, which are on in the version the server is using (4.4.0), but off by default in my version, (5.1.1), which is why I didn't experience the problem on my computer. Nonetheless, the solutions for this problem are here: http://www.nyphp.org/phundamentals/ini.php

 

The part that I am interested in is the section entitled: When You Don’t Control the Server. In particular, I am interested in option 3, which is about using a .htaccess file. Of course if that method doesn't work, I would like to do the others.

 

The sample code provided at the website for the .htaccess file is the following:

 

php_value include_path .:/path/to/global/includes:/path/to/local/includes

php_value register_globals 0

php_value error_reporting E_ALL

php_value display_errors 1

php_value auto_prepend_file path/to/my/functions/library/masterfile.php

 

 

First of all, before I begin going through each line, I would like to know, where do I put this .htaccess file? In the same section where all my other files are at on the server? Also, would the file be saved as just .htaccess?

 

O.k. Now, the two main things that I would like clarification on are the first line and last line of the sample code I provided.

 

Starting with the first line: My include_path listed under the heading of local value and master value as .:/usr/local/lib/php and .:/usr/local/lib/php

 

So, will my first line be like this: php_value include_path .:/usr/local/lib/php:/.:/usr/local/lib/php

especially, the part after the letters php? (:/.:/)

 

And also, for the last line, what do they mean by masterfile.php

And will the last line look like this....Actually, I don't know what goes there. I was reading about library functions and came up with the conlusion that this had something to do with curl. If this is the case, this is the information listed for that: CURL Information libcurl/7.11.2 OpenSSL/0.9.7d ipv6 zlib/1.2.1.1

Under the auto_prepend_file section, for local and master value, I have listed No Value

 

And a quick question about creating a local php.ini file. It's pretty much the same questions I posted about the .htaccess file.

 

The sample code provided at the website is:

 

include_path = .:/path/to/global/includes:/path/to/local/includes

register_globals = 0

error_reporting = E_ALL

display_errors = 1

 

Will the include path be .:/usr/local/lib/php:/.:/usr/local/lib/php (If I posted it correctly the first time, then I am pretty sure it will be like this again, but I just want to be absolutely sure.)

 

Also, where would the php.ini file go: in the same places where my other files are at on the server?

 

I hope someone can offer me some help with these issues and am thanking you in advance for any and all help.

Link to comment
Share on other sites

Through your research you will know that this value can only be altered in php.ini, httpd.conf or .htaccess.

 

In addition you need the server that your site is on to allow you to alter php flags in the htaccess file. This is dependant on what AllowOverride si set to in the server config file - something you have no control over.

 

I am not sure what the seting needs to be to allow you to set php_flags in teh .htacces file but your server support people should be able to help.

 

Note: some hosts won't enable anything extra for you on shared hosting - they will say you need a dedicated server (as fasthosts did to one of my sites recently) you DON'T need a dedicated server but you may have to switch hosts

Link to comment
Share on other sites

if all you want to do is turn off register globals then all you need to do is add the following to the .htaccess file:

php_flag register_globals Off

 

You do not need to alter any other PHP setting.

 

When creating the .htaccess file it should be named just .htaccess (not filename.htaccess). This file should be placed in your document root of the server (the folder where you upload all your website files to).

 

Also in order for the server to acknowledge the php_value/php_flag directives in the .htaccess file the AllowOverride directive must be set to either FileInfo or All in the httpd.conf. Also PHP must be loaded as an Apache module too. If its loaded as CGI then you wont be able to use the php_value/php_flag directives in the .htaccess file and you'll most likely get an Internal Server Error message too.

 

You cannot create you're own custom php.ini either this down to the webhosts discretion.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.