Redirect through .htaccess file

Here’ s the logic to redirect particular page through .htaccess file.

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

as given above,
here is the url of the site you want to redirect. here if the url typed in the address bar is, it will redirect to

the above given logic will work for apache webserver only as .htaccess file is supported by apache webserver and not IIS webserver. In case you have an IIS webserver here’s something you can do.

But this logic has to be written in php file. The logic follows as below:


header( “HTTP/1.1 301 Moved Permanently” );
header( “Location: http://www.&#8221;.$_SERVER[‘HTTP_HOST’].$_SERVER[‘PHP_SELF’].’?’.@implode(‘&’,$_SERVER[‘argv’]));
header( “Location: http://www.&#8221;.$_SERVER[‘HTTP_HOST’].$_SERVER[‘PHP_SELF’]);




Remove blank spaces and new lines from string

you can use the preg_replace function to compress a given string and remove spaces and blank lines from the string.

The use of the function is as given below:

preg_replace(“/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/”, “\n”, $string);

where “$string” is the string you want to remove the spaces and blank lines from.

if in case the above code doesn’t work properly you can use the below given user-defined function :

The Function:

function my_preg_rep($content_area){
$content_area=preg_replace(“/[\r\n]*/”, “”, $content_area);
$content_area=preg_replace(“/[\r\n]+/”, “”, $content_area);
return $content_area;

Code :

echo my_preg_rep(addslashes($content_area));


Sachin (

Automatic destructor in PHP4

class demoClass{

function demoClass(){
register_shutdown_function(array(&$this, ‘__destruct’));

$argcv = func_get_args();
call_user_func_array(array(&$this, ‘__construct’), $argcv);

function __construct(){
//your code for constructor goes here

function __destruct(){
//your code for destructor goes here


//Hope this method help you out with your problems.

//Hope this helps you,

//Sachin (