Oct 23, 2010 | Apache Server, htaccess
One common approach of code migration. Redirect normal users to maintenance page while migration testers carry out production testing after completion. The solution – amend our .htaccess file to redirect all incoming request to maintenance except for request from testers’ office IP address. #.htaccess RewriteEngine on #Check if request is not server_down_message.html and ip is not from testers' ip address #Change xxx.xxx.xxx.xxx to your ip address, eg. 202.126.4.10 RewriteCond %{REQUEST_URI} !/server_down_message.html$ RewriteCond %{REMOTE_HOST} !^xxx.xxx.xxx.xxx #To allow more IP addresses, simply append "RewriteCond %{REMOTE_HOST} !^xxx.xxx.xxx.xxx" under this line #Both conditional are true #Not requesting for server_down_message.html and IP address not from tester. #Redirect to server_down_message.html RewriteRule $ /server_down_message.html [R=302,L] Hope it helps you and good luck with your...
Oct 21, 2010 | date and time, PHP
To display current date we use the date function in PHP. <?php //string date ( string $format [, int $timestamp ] ) echo date("Y-m-d H:i"); ?> Result: The date() function requires 1 parameter which is the string format to format the current date time to our liking. Refer to the php date documentation for more details on the formatting string. The 2nd optional parameter which takes in an integer value representing the date time comes in handly where in some situation, we need to display specific dates. We use mktime() function to create the specific date time. <?php //int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] ) //mktime(8,0,0,10,20,2010) creates a date time specific to 20th October 2010, 8:00 am echo date("Y-m-d H:i",mktime(8,0,0,10,20,2010)); ?>...