Disable PHP in a directory with Apache .htaccess

If you have a directory which users can upload files into it’s a good idea for security reasons to disable server-side parsing of scripts such as PHP. This post shows a couple of options using Apache’s .htaccess files.

PHP’s file_get_contents and CURL functions

This is a summary of the posts I've written about PHP's file_get_contents functions when used to download remote content (e.g. webpages, XML files, images etc) and the CURL functions which are used to do the same thing.

Categories PHP

Disabling PHP short tags in an Apache .htaccess file

PHP code in a script is commonly delimited by opening <?php and closing ?> tags but there are also the older short open tags like this <? There are instances where you may need to disable short tags as shown in this post and using an Apache .htaccess file.

Setting 503 Service Temporarily Unavailable headers with Apache .htaccess

When temporarily taking down a website to perform maintenance, it’s a good idea to return a "503 Service Temporarily Unavailable" header so search engines know to come back later. This post shows how to set this header using an Apache .htaccess file, and also how to show a response page to users with PHP so they know to try again later.

Handling errors when connecting to a database using PHP PDO

PHP’s PDO database abstraction class offers a better way to connect to databases than the mysql_* etc style functions, or using a 3rd party database library. This post looks at handle errors when connecting and a follow up post later this week will look at how to check for errors when running individual queries after a connection has been successfully established.

Categories PHP