FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home » PHP »  PHP htaccess tips and tricks

PHP htaccess tips and tricks

by Charles Torvalds 3 comments

[hide]

Htaccess php tips and tricks for the Apache HTTPD Web Server, mostly these tips show you how to run customized versions with customized php.ini files, I require custom php.ini files because they are so useful!

Even more detailed php tips can be found at custom php.ini tips and tricks


| .htaccess Tutorial Index |


PHP htaccess tips

Setup PHP when run as CGI / suexec

Place your php.ini file in the dir of your cgi'd php, in this case /cgi-bin/, .htaccess might look something like:

AddHandler php-cgi .php .htm
Action php-cgi /askapache.com/cgi-bin/php5.cgi

Use a custom php.ini with mod_php or php as a cgi

Article: Custom PHP.ini tips and tricks

PHP run as Apache Module (mod_php)

Add this to your root .htaccess file. Say your php.ini is in folder /askapache.com/ini/

SetEnv PHPRC /askapache.com/ini

Custom php.ini with wrapper for FastCGI and PHP

You can use FastCGI on php by creating a php binary for cgi execution, then you create a fcgi wrapper script that execs the php using FastCGI

Article: Custom php.ini/FastCGI/DreamHost

#!/bin/sh
export PHP_FCGI_CHILDREN=3
export PHPRC=/askapache.com/ini
exec /askapache.com/cgi-bin/php.cgi
# or
#exec /askapache.com/cgi-bin/php.cgi -c /askapache.com/ini/php.ini

htaccess Guide Sections

| .htaccess Tutorial Index |



April 10th, 2007

Comments Welcome

  • Shiva Awast

    I'm working as a php programmer and I want to url rewriting in my localhost

    I have no idea in url rewriting for localhost issues, pls give me any solution

  • http://diogomelo.net Diogo

    You can also make Apache leverage browser cache, for static files like css, png, jpg.... It speed up page loading :D

    http://diogomelo.net/drupal/blog/10/setting-header-parameters-apache-using-htaccess-error-500-internal-server-error

  • http://www.thevinayak.com Tarun Agarwal

    hello Buddy,

    i am receiving message as

    Warning: Unknown: open(/tmp/sess_1, O_RDWR) failed: Permission denied (13) in Unknown on line 0
    Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

    and then my site is not able to publish the php contents..i am afraid whts going on..
    can you help me out in understanding this and a solution for this through htaccess

    Regards,

    Tarun

My Online Tools
Twitter

  • askapache:  t.co/C91g6Ra3Uf  - coreboot has been accepted to participate in Google Summer of Code, 2013
  • askapache: Today in 1965 DEC announces PDP-8
  • hubail: RT @askapache: Make sure you unplug your Ethernet when leaving the room, or disable wifi
  • askapache: Make sure you unplug your Ethernet when leaving the room, or disable wifi
  • askapache: My servers, and me, are getting annoyed. Fail2ban works fairly well against all the Chinese brute forcing going on
  • askapache: Can't the Chinese stop ordering their hackers to hack us? Ugh
  • askapache: All I want for my bday is a bottle of American whiskey :)
  • askapache: The first Dino fossil wasn't found until 1822, we sure are young

My Picks

Related Articles
Newest Posts

WordPress Development
Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two. See my article, On Hacking.
-- Richard M. Stallman






It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service

↑ TOPMain