No need to use PHP if it is an Apache...

.htaccess is also easy but definitly not a "dirty" trick