tip of the day: php settings via htaccess

Posted Friday, February 3rd, 2006 at 2:44 pm by Richard in the geek, web category.

Okay, this has been covered a lot but I find it very handy so maybe it will help someone…

Did you know you can change many PHP settings through .htaccess files?

Example
When you’re trying to get your pages to validate but the dratted ampersands in links foul it up – even though you’ve correctly escaped them in your code eg

index.php?t=thing&s=stuff

but they still come like

index.php?t=thing&s=stuff

So to fix this you need to change a couple of PHP settings which generally would mean trawling through the server and editing php.ini, which in turn may not be possible for many hosted sites as many IPS’s simply don’t give access to this for good reason.

In this case (and to help make your site more portable) in your htaccess file just add…

php_value arg_separator.input ;&
php_value arg_separator.output &

This is just one example, there’s plenty more you can do.

For more on htaccess and php settings see Sopel and corz and of course the PHP documentation

Comments...