Using the .Htaccess File for PHP Directives

The .htaccess file is pretty handy as it can also allow you to set various PHP flags that you may not want enable for all of you websites and in turn will let you run just about every PHP flag or directive on a one on one website basis.

You will need to log into your Linux server directly using SSH. 

To create the .Htaccess file, you meerly need to create a text file with any Linux editor. The file must be called .htaccess and it must exist in the root directory of the website you want override the Php global directives for. 

The format of the .htaccess is simple, however you will want to comment out exactly what flag or directive you are enabling for the site. An example of this would be as seen below;

#Turn register goabls of
php_value register_globals off

#Php max upload size
php_value upload_max_filesize 12M
php_value post_max_size 12M

#Enable another version of php if you have two installed (Enable Php 5)
AddType application/x-httpd-php5 .htm .html .php

Make sure you save the file when you are done editing it.

Just about any directive or flag can be added to the .htaccess file so you can commently customize the php functions of the website instead of changing it globally in the php.ini file. For a list of what you can use, please review the PHP manual at http://php.net/manual/en/index.php.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Installing htop

htop is an interactive process viewer for Linux, which is a powerful alternative to the...

Bind Multiple IP Addresses to a Single Network Interface Card (NIC)

This tutorial demonstrates how to bind multiple IP addresses to a single NICI'll be using LAN...

Clear Memory Cache on Linux Server

By default the Linux OS has a very efficient memory management process that should be freeing any...

Set the time on a Linux server

Log into the server via SSHAt the shell prompt run the following command:date MMDDHHmmYYYYFor...

Check your disk usage in Linux

A good way to check your disk usage for folders on your Linux server is via shell.Download...