Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


using .htaccess to configure PHP

Posted on 2010-01-09
Medium Priority
Last Modified: 2013-12-13
We use a 3rd party hosting service to host our PHP-enabled websites. They have blocked access to php.ini, so I read up on php.net about using .htaccess files to set configuration directives.

In a directory I use for learning PHP, called _learning, i created a .htaccess file with the following contents, in order to override values in PHP.ini (see code window):

..but when I accessed a php script in this directory, I got a server error.
There was no entry in the error_log afterwards
If I comment out the last line in .htaccess, the script works as normal.

any ideas?
Is use of .htaccess disabled? I don't think so because I think a colleague used them before, but how can I tell?
Am i using correct format?
#php_value name value
#php_value pcre.backtrack_limit "100001"
php_flag session.auto_start on

Open in new window

Question by:zorba111
LVL 34

Accepted Solution

Beverley Portlock earned 1000 total points
ID: 26274942
Put this in your .htaccess in your test folder

Redirect permanent / http://news.bbc.co.uk

Then go http://mydomain.com/_learning/ and you will be redirected to the BBC news page if the .htaccess is working

LVL 82

Assisted Solution

hielo earned 1000 total points
ID: 26274962
ask your webhost if you can use a custom php.ini file. For instance, in the past I've used the following in an .htaccess file:
SetEnv PHPRC /path/to/my/custome/config/file

when my site was executed, the server was loading:

As for "Is use of .htaccess disabled?"
If the server has a :
php_admin_flag session.auto_start off

then you would not be able to override that with
php_flag session.auto_start on

So see if you can use your own php..ini file

Author Comment

ID: 26275170
This is what the hosting ppl said:

Our servers do not support PHP directives in .htaccess due to suPHP that we have to used in a shared environment.

so that's that !

I found a way around the immediate need to configure include_path (i.e. just specify the library with complete path)

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question