Monday, May 18, 2009

Well done Sri Lanka

Congratulations Mr. President Mahinda Rajapaksha and Sri Lankan forces for freeing the nation from terror by defeating LTTE, which is the most ruthless terrorist outfit in the world. The good news was informed officially on yesterday 18th May 2009 evening.

Wednesday, May 6, 2009

Convert url from non-www version to www version or vise versa


Redirect with Apache
Redirect www to non-www:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,L]


An alternative which includes domain name is as follow:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

The following is the version to redirect non-www to www:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

WWW Redirect with nginx

Redirect to non-www, add the following code:

server {
listen 80;
server_name www.example.com;
rewrite ^/(.*) http://example.com/$1 permanent;
}

The word permanent is key. It turns the redirect into 301 redirection. After this block, you may configure the domain without www.

Redirecting non-www to www:

server {
listen 80;
server_name example.com;
rewrite ^/(.*) http://www.example.com/$1 permanent;
}

WWW Redirect with lighttpd

Redirecting www to non-www can be done with the following code:

$HTTP["host"] =~ "^example]\.com$" {
url.redirect = ( "^/(.*)" => "http://www.example.com/$1" )
}

Redirecting non-www to www:

$HTTP["host"] =~ "^example]\.com$" {
url.redirect = ( "^/(.*)" => "http://www.example.com/$1" )
}

Subscribe