.htaccess 301 Redirect

I used this .htaccess 301 redirect trick I found. This way is better than meta refresh or redirect tag because there is no delay as the browser reads the .htaccess file first. However, it is only available to Linux server (doen’t work on Window server).

Open the .htaccess file and do the following chnages

To redirect certain page(s):

Redirect 301 /oldpage.html http://www.mysite.com/custom.html
Redirect 301 /oldpage2.html http://www.mysite.com/myfolder/

To redirect entire site:

Redirect 301 / http:/www.blogger.com/

Get IP of user system

function checkIP($ip) {
if (!emptyempty($ip) && ip2long($ip)!=-1 && ip2long($ip)!=false) {
$private_ips = array (
array(’0.0.0.0′,’2.255.255.255′),
array(’10.0.0.0′,’10.255.255.255′),
array(’127.0.0.0′,’127.255.255.255′),
array(’169.254.0.0′,’169.254.255.255′),
array(’172.16.0.0′,’172.31.255.255′),
array(’192.0.2.0′,’192.0.2.255′),
array(’192.168.0.0′,’192.168.255.255′),
array(’255.255.255.0′,’255.255.255.255′)
);

foreach ($private_ips as $r) {
$min = ip2long($r[0]);
$max = ip2long($r[1]);
if ((ip2long($ip) >= $min) && (ip2long($ip) checkIP($_SERVER[”HTTP_CLIENT_IP”])) {
return $_SERVER[”HTTP_CLIENT_IP”];
}
foreach (explode(”,”,$_SERVER[”HTTP_X_FORWARDED_FOR”]) as $ip) {
if ($this->checkIP(trim($ip))) {
return $ip;
}
}
if (checkIP($_SERVER[”HTTP_X_FORWARDED”])) {
return $_SERVER[”HTTP_X_FORWARDED”];
} elseif (checkIP($_SERVER[”HTTP_X_CLUSTER_CLIENT_IP”])) {
return $_SERVER[”HTTP_X_CLUSTER_CLIENT_IP”];
} elseif (checkIP($_SERVER[”HTTP_FORWARDED_FOR”])) {
return $_SERVER[”HTTP_FORWARDED_FOR”];
} elseif (checkIP($_SERVER[”HTTP_FORWARDED”])) {
return $_SERVER[”HTTP_FORWARDED”];
} else {
return $_SERVER[”REMOTE_ADDR”];
}
}
//Override server variable for Wordpress comments
$_SERVER[”REMOTE_ADDR”] = determineIP();

Javascript validation for URL

function imp_isUrl(url) {
return url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s\#%”\,\{\}\\|\\\^\[\]`]+)?$/);
}

to allow #,%,[,] in url use below regular expression
return s.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s”\,\{\}\\|\\\^`]+)?$/);

Zend Server talks Java, says 'no rush' for PHP 6

Zend is one of many open source success stories. Following a model that's proved strong with MySQL and Subversion, it provides support and commercial software that sits alongside mainstream PHP use, targeting enterprise customers who need high-reliability, high-scalability web app servers.

The company has announced software called Zend Server, an all-in-one bundle for running PHP applications on between one and three servers. It includes a highspeed code cache, which makes nearly every PHP run faster – sometimes by a factor of 10. It also monitors all the PHP scripts running across your servers, providing feedback on where things are running slowly and where errors occur. more

Zend Server talks Java, says 'no rush' for PHP 6

Zend is one of many open source success stories. Following a model that's proved strong with MySQL and Subversion, it provides support and commercial software that sits alongside mainstream PHP use, targeting enterprise customers who need high-reliability, high-scalability web app servers.

The company has announced software called Zend Server, an all-in-one bundle for running PHP applications on between one and three servers. It includes a highspeed code cache, which makes nearly every PHP run faster – sometimes by a factor of 10. It also monitors all the PHP scripts running across your servers, providing feedback on where things are running slowly and where errors occur. more

PHP 5.3 coming June 30th

From the 'whatever happened to PHP 6?' files:

PHP 5.3 could be out as soon as Tuesday June 30th. The new open source language release is a big deal for a lot of reasons, not the least of which is the fact that by my count this is the first major update to PHP since 2006 and the PHP 5.2 release.

PHP 5.3 is also interesting in that it includes at least one key feature that was originally intended for PHP 6 (whenever -- if ever -- that release will be out).

I spoke with Zeev Suraski, co-founder and CTO at commercial PHP vendor Zend Technologies last month about PHP 5.3. He noted that one key feature backported from PHP 6 into PHP 5.3 is namespaces, which is a way to encapsulate classes and other PHP items more easily.

While the official release is on June 30th, support for PHP 5.3 is already present in development tools from Eclipse released this week.

*UPDATE JUNE 30TH - PHP 5.3 did get released - full story is up on the main site.

The Eclipse Galileo release include the PHP Development Tools 2.1 (PDT) application which has PHP 5.3 support. Zend which backs the PDT effort, now has a commercial tool in beta that builds on the PDT 2.1 release as well.

Zend Studio 7.0 is currently in Beta and according to Zend also includes new enhanced source code editing for PHP as well as improved integration with the Zend Framework. By my count, the Zend Studio 7.0 beta is the first major upgrade to Zend Studio and a year and half when Zend pushed out its first IDE based on Eclipse.

The new PHP 5.3 release is coming at a critical time for the PHP community in my opinion. It is continuing to face pressure on the web development side from Ruby and in the enterprise space, .NET and Java are evolving themselves as well.

Why PHP 6 has not been released yet is a question that I ask PHP language developers often and regularly. While PHP 5.3 is not the big evolution that PHP 6 might end up being, PHP 5.3 is likely a key incremental step in the evolution of PHP. more

Wi-fi 'to get a whole lot easier'

The world of wi-fi is to become a whole lot easier thanks to a major technology upgrade, says an industry group.

The Wi-Fi Alliance said it would soon finish work on a new specification called Wi-Fi Direct.

It will let wi-fi devices like phones and laptops connect to one another without joining a traditional network.

The Wi-Fi Alliance - whose members include Intel, Apple and Cisco - hopes devices with the new technology will be on the market by the middle of 2010. more