SEO Canonicalization using htaccess

August 14, 2010 by rooturaj  
Filed under Search Engine Optimization

Hola webmaster… since you are here I assume you are looking for a solutions to redirect duplicate looking and sounding pages on your website to a global format. In the next 3 minutes you are going to do exactly that. Read on…

By the way did you know search engines see www.domain.com , domain.com and domain.com/index.php as three separate pages. So when the search engine arrives on the site it get confused.

SE Bot: What the hell? Which one is the right URL? Ok let me pick one which ever i think is good.

What you should do? You need to 301 redirect all the versions to one global version.

Ok enough Rambling Mr Pattanaik, tell me how to do it.

Well yeah. I use the htaccess method in apache servers. Here is how to do it for your website using htaccess.
Step 1: Create an HTACCESS file. Open notepad save the file as .htaccess …thats it.
Step 2: Add this code to the file in editor.

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

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

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.com/$1 [R=301,L]

Step 3: Thats all. Upload the file to your root directory of the domain. Dont worry its not a virus or spam bot I am asking you to upload.

Now Share this post if you find it helpful.

Related Posts:

  • No Related Posts

Text content outside Div IE | Duplicate Characters Bug IE6

July 14, 2010 by rooturaj  
Filed under Programming

Hey Programmer,

Since you are on this page I know you are a web developer.  Cheers mate. I hope you have not spent one whole night awake and skipped dinner like me when you had a deadline and Microsoft Internet Explorer acted up. Especially the God Damned IE6 which should, IMHO, be banned and all users using that browser be taxed $1000 a year as Anti-Development tax. I am not exaggerating. We waste our time and electricity on fixing code for IE6 and that should be charged on users who don’t upgrade to Firefox or Opera or Chrome.

Anyway I wanted to share with you a peculiar error on IE6. You see parts of your content duplicated for no apparent reason. If it not aligned properly or breaking orientation its understandable…but showing some characters that make the end of the content is just outrageous.  Now see this example -

a simple instance of the bug - snapshot

a simple instance of the bug - snapshot

Notice the pink area in the footer. I have set the height of container divs and the two yellow/blue halves as same. The last three characters of my content in right half is being duplicated.  I know its like majic but who the hell likes this shitty magic?

How to recreate the bug?

<!--main div statrs here-->
</code>
<div style="height: 300px; width: 300px; background: none repeat scroll 0% 0% #ffccff; float: left;">
<!--sub div statrs here-->
<div style="height: 300px; width: 300px; background: none repeat scroll 0% 0% #ffccff; float: left;">
<!--left div statrs here-->
<div style="height: 300px; width: 150px; background: none repeat scroll 0% 0% #ffff99; float: left;">This is content in left div. This is content in left div. This is content in left div. This is content in left div. This is content in left div. This is content in left div. This is content in left div.</div>
<!--left div endshere-->
<!--right div statrs here-->
<div style="height: 300px; width: 150px; background: none repeat scroll 0% 0% #00ffff; float: left;">
Right div text material here. Right div text material here. Right div text material here. Right div text material here.Right div text material here.Right div text material here.Right div text material here.</div>
<!--right div ends here-->
</div>
<!--sub div ends here-->
</div>
<!--main div ends here-->

How to fix this IE duplicate characters issue?

The fix is rather simple .. You got to limit the use of comments. Yeah…for some ‘God Knows Why’ reason using comments can lead to bugs in your HTML coding. From what I have read about this ..it seems IE6 has a margin buffer on right..that is if you have a box with 100px width you cannot have two boxes inside it with 50px width each.

1. You need to provide atleast 3px free space on right so that Microsoft guys might stick their thing there. (sorry for being rude)
2. Else you need to remove the comments. The comments seem to trigger the bug in most cases.

Either one of the fixes or their combination should work for you. If it does not you can curse me in the comments for wasting your time and continue your search on internet.

Related Posts:

Fix : Product Installation Unsuccessful Please Reinstall Error 24 – Corel Photo Paint, CorelDraw etc dead June 1st 2010!

June 10, 2010 by rooturaj  
Filed under Technology

orDear Reader,

I bring to you this fix to the recent global Corel installation unsuccessful error. Some thing that gave us this annoying messagebox. Thanks to Mohd Saqib for the tip off and the fix.

corel-uninstallation-error

You would be glad to know that we have found the fix to the problem.You need to down load this file extract the files and copy it to the following path on your system.

C:\Documents and Settings\All Users\Application Data\Corel\CorelDRAW Graphics Suite X
or try this path….
C:\Documents and Settings\All Users\Application Data\Corel\CorelDRAW

Here we are assuming you run windows PC. In case this does not work for you…there are other simple solutions like running the Corel software by changing your system date to any date earlier than 1st, June 2010. Even Corel has confirmed the bug and will issue an update for the users soon.

You may also be interested in the RunAsDate application that can run a particular software in a previous date without affecting other software and the OS.

Update: Some of you have asked about the right place to add the patch in Window Vista.
use this path – Computer/C:/Program Data/Corel/CorelDraw Graphics Suite X4
Thanks to Estee and Saqib for the updates.

Related Posts:

  • No Related Posts

HDFC- Smart Shoppers is a reported attack site

June 5, 2010 by rooturaj  
Filed under Business, Online Security

Was feeling like buying an Olympus Digital SLR cam today. The HDFC guys sent me a flyer with the specification and I was pretty happy with it.  So I call up the phone-banking service to order the cam. They tell me you need to order it on HDFC site. Fine, so I am on the HDFC shopping site and look what I get …

HDFC shopping reported hacking site

Bl0ody hell ! this is what our top urban bank has to offer us? See what the firefox report has to say about this.

This page tries to install programs that steal private information and use your computer to attack others or damage you computer.

This site is probably not a direct HDFC property. They are kind of affiliates through which they help sell consumer goods through easy installment system on their credit cards

Anyway I tried to open the same site in Opera Browser and it did not have a problem opening the site. But I could not find the product they had sent the flyers about. So I felt like contacting them online. I click the contact us link and this is what I get..

HDFC shopping contact us

And everyone wonders why is Online Shopping not so popular in India? HDFC is the most Tech Savy bank in India in my opinion. Now this is what they offer. One sentence saying enter your contact information here. What next…? Design error? Cross browser compatibility failure? Whatever it is, it only pisses of a user.

I will of course be directing the attention of HDFC people about this and at the same time would like you to share it with your friends so that they are aware of the Crap they are being supplied with in the name of online technology.

Related Posts:

Hoax: Google enters SEO Business

April 30, 2010 by rooturaj  
Filed under Search Engine Optimization

Now News Wire dropped a bomb yesterday declaring that “Google is planning to enter SEO Business”. But they just forgot to pack some explosives into that bomb. The result of that crazy post by Serena Shaper0 c was that half the SEO world got perturbed real bad. Questions flew everywhere and Facebook and Twitter went crazy with Serena too? How can you dare make such bid claims without valid proofs? The SEOs may be mystics but they are not dumb.

Funny thing is that some people will believe anything they read. They dont even bother to cross check the validity of the claims made by the other person. So I took some time to dig out the fact behind this all. First I arrived at this Google Forum post where a concerned SEO wanted an answers from professional whether Google is really planning to kill our profession? Similarly our dear old Matt Cutts clarified this on his twitter account.

google-enters-seo-business-hoax

Apparently google did post something like this on 1st April and we know how to deal with such big announcements. Remember BBC once claimed with an online show on April fools day about the improving harvest of Spaghetti noodles where europeans were plucking noodles from trees?  Ha ha… So our funny reporter found the article some 27 days latter and lost her brains over it.

Hey You...its a April Fools Joke

The final product is that we have the hoax circulating the whole web and spreading like hell fire.

Related Posts:

Displaying HTML DIV above flash content (transparency + z-index)

April 14, 2010 by rooturaj  
Filed under Programming, Technology

We have faced this problem many of the times. When we want to display some message on top of all layers on a page or use some feature like jQuery light boxes. Normally the flash file continues to shine through the page. No matter what you do with layering the dom elements using z-index.

See the layering flash content problem definition here.

Before this, people used to dodge this issue with some fixes like hiding the flash area completely and then showing a static image of the html file in its place. Then it gave a semblance of layering flash beneath html content. But since flash 9 we can layer flash elements under html with ease.

See the solved situation where we have content over flash.

What you need to do to achieve this?

Nothing much. You set z-index value to your divs. Say we have a flash div (#flasho), a div for creating a the transparent layer (#transo), and the div for displaying content as a light box (#boxo)

Here is the css for them all. There is also the javascript code for the effect call on button click. (see solved example link above.

<style type="text/css">
#flasho{z-index:0;}
#boxo{top:200px;left:400px;border:1px double #600;width:532px;height:210px;margin:0px;z-index:100;position:absolute;display:none;background:#FFFFFF;}
#transo{background:#000000;height:400px;;width:100%;-moz-opacity:.80;top:0px;left:0px; filter:alpha(opacity=80); opacity:.80;display:none;position:absolute;z-index:99;}
</style>
<script type="text/javascript">
function addthiseffect()
{
document.getElementById('transo').style.display="block";
document.getElementById('boxo').style.display="block";
}
</script>

Now for the flash part we need to do this little addition. Add wmode=”transparent” to the <embed> tag and <param value=”transparent” /> to the <object> tag. See my Flash code below that I have used in my example.

<div style="float:left;width:343px;height:160px;margin-top:7px;z-index:0;">

<OBJECT

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"

WIDTH="343" HEIGHT="160"><PARAM VALUE="flash/course-in-aviation.swf"><PARAM VALUE=high><PARAM VALUE=#00000><param value="transparent" /><EMBED src="flash/course-in-aviation.swf" quality=high bgcolor=#FFFFFF WIDTH="343" HEIGHT="160" wmode="transparent"

NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"

PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>

</div>

Related Posts:

Editing PNG image in Photoshop | locked background layer in Photoshop

March 27, 2010 by rooturaj  
Filed under WebDesigning

Hey Designer! Wassup. I assume you to be a designer working with photoshop. Else you would not have been here. Any way lets get to the point straightaway.  You are here because you

Cannot edit a PNG file in photoshop or probably your background layer is locked.

Further you are not able to create any layers using marquee tools or change colors using the change hue saturation options. Probable all major functions are disabled as well. You might be seeing a lock icon on your main image that is now the back ground layer.

If you have the problems as mentioned above try these simple steps and you would be doing good in no time.

1. Double click the lock icon. If it unlocks then you can try editing and see if everything is all right. If no try the next step.
2. Try to save the PNG image or whatever you are working on to jpeg format. Now open it in photoshop and try to edit. Working ? No? then try the next step.
3. Try to edit the color scheme to RGB.

Related Posts:

  • No Related Posts

Accessing PHP Cookies from different directories or domain path

February 25, 2010 by rooturaj  
Filed under Programming

It is pretty easy to work with cookies. They are really tasty. I am talking about PHP cookies and yeah we programmers can taste them. I will be highlighting some ‘not so common’ points about cookies today. Ready?? Lets Go.

What are Cookies?

These are little bits of information stored on your computer by a website. The specialty of these bits is that they can only be opened by the site that stores it in first place. So Google’s Cookies are invisible to Yahoo’s and same the other way round. Cookies can be set for a particular time span and deleted by the site that created it. The user can also clear cookies whenever he wants to from his browser or manually from the personal folders of his system.

Now we know that Cookies are store houses for secure information that we webmasters use to dish out customized content to our visitors. They are widely used for storing user login information and shopping cart contents so that even if the user closes the browser and comes back the site allows access and restores his shopping cart. We could even use it to store your theme choice for sites or to tell you when you visited last time.

How to set a cookie Using PHP?

Its pretty easy. Use this  code.

<?php 

// set a cookie named 'pingu' with a value of 'Penguin'
setcookie('pingu', 'Penguin');

?>

Recalling and using the set Cookie

We use the super global variable $_COOKIE  to  call the stored value of cookie the same way we do with $_GET and $_POST.

<?php 

// We  will  use ‘pingu’ cookie  in a sentence.
echo "Pingu is a ".$_COOKIE['pingu']."."; 

?>

Output: Pingu is a Penguin

Setting  a  time span for your cookie.

For security purposes we need to set some cookie expiry time. Some sites even ask the user how long to store his cookie. Others have a default expiry period. After this time your cookies is dead and you need to log in again to use the site. (or any other similar functionality)

<?php
$time = 7*24*3600 + time() ; //no of secs to store the cookie

// set a cookie named 'pingu' with a value of 'Penguin' for  2  days
setcookie('pingu', 'Penguin', $time);

?>

Accessing a Cookies from a different directory of domain.

Now when using the previous methods to set cookie will restrict the access to the directory where it was originally set. Eg. If you set the cookie on file domain.com/user/setcookie.php you cannot retrieve the cookie  on domain.com/member/getcookie.php. To get around this we need to set an accecibility parameter as well. See below.

<?php

// set a cookie named 'pingu' with a value of 'Penguin' for 2 days  through out the domain.
setcookie('pingu', 'Penguin', $time, “/”);

?>

Now you cookie can be called from any part of the domain.  But it’s a not much recommended. Similarly you can specify particular directories/folders to access the cookie. Like “/user/” or “/member/” instead of “/”.

Overall Syntax format – setcookie (‘[string]’,’[string]’,[integer],’string’);

Related Posts:

Setting Excel background and Printing a Spread-sheet with Background

February 2, 2010 by rooturaj  
Filed under Software

This post is to address an every day issue that you face when working with spread sheets (MS Excel – OpenOffice Spreadsheets etc). We normally cannot print spreadsheets with a background. I mean when you print the document it does not show the background graphic.

When confronted with this problem I googled it up. (Sorry can’t help. it’s a habit) Now Microsoft, as we all know, are charming people who love it when you have trouble using their product. They said “This issue occurs because background graphics cannot be printed in Excel.” How smart and what a useful answer. Guess what they even ask “Did this information solve your problem?” I felt like kicking that bloke who wrote this in the ‘you know which’ place.

Ok enough.. Now here is the solution.

Setting a background for your Microsoft Excel Spreadsheet

backgorund-excel

I hope the screen-shot would suffice. All you need to do is go to the main menu. Then Choose Format >> Sheet >> Background.

Browse the image file and select it.

The back ground will get tiled all over the work area. There is no overriding this I guess. So choose a proper sized graphic to fit your printable area.
Tip: Use white space around the image (photoshop or other graphic tool) to fit it wherever you want on the printable area. See this example.

Seriously I do

Seriously I do

Now if you want to print the same you would never get the background. Try and check the print preview.

So How to Print the Spreadsheet along with the Background?

Save the file as webpage. (.html or .htm)

Then open the file in your browser and print as you like. Remember to do the print set up properly. On my Firefox I do this.

print-setup

Hope that helped.

Related Posts:

PHP Image Resize script – Resize Images on the fly

January 30, 2010 by rooturaj  
Filed under Programming

What does this Script do?

It changes the dimensions and hence the file size of  image files on the fly. All you need to do is specify a source file, set the new dimensions and this PHP class will generate the new re-sized image for you.

Who should use this?

Any one who needs to re-size their images automatically.

For example: If you need to generate thumbnails for the images uploaded to your image sharing site then this is the solution for you. Sometimes we need to display smaller images to save band width and improve page load time.

What does this need?

PHP 5 + GD Library

(and of course the image files to manipulate and apache server)
To check if you have got GD library on your PHP bundle Create a php file with the following code and run it.

<?php
phpinfo();
?>

Let’s get working then.

Here is the Class File. It contains two functions resize() and resize_const(). The first one only takes in a width value with the source file and generates a new image with height in constrained proportions. While resize_const() takes in width, height and source file to generate an image of exact dimensions.


<?php
class ImgResizer {
private $originalFile = '';
public function __construct($originalFile = '') {
$this -> originalFile = $originalFile;
}
public function resize($newWidth, $targetFile) {
if (empty($newWidth) || empty($targetFile)) {
return false;
}
$src = imagecreatefromjpeg($this -> originalFile);
list($width, $height) = getimagesize($this -> originalFile);
$newHeight = ($height / $width) * $newWidth;
$tmp = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if (file_exists($targetFile)) {
unlink($targetFile);
}
imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for
//output image quality with 100 being the most luxurious
}

//the function below will get you an image with the width and height values set by you.
// In case you need exact size images.
public function resize_const($newWidth,$newHeight, $targetFile) {
if (empty($newWidth)|| empty($newHeight) || empty($targetFile)) {
return false;
}
$src = imagecreatefromjpeg($this -> originalFile);
list($width, $height) = getimagesize($this -> originalFile);
$tmp = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if (file_exists($targetFile)) {
unlink($targetFile);
}
imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious
}
}
?>

Using the Class and the Functions.

Use the code below in as where ever you want it to work. (I am sorry but that does not include pasting the code on your photo frame)


<?php
$work = new ImgResizer('path/to/original/image.jpg');
$work -> resize(75, 'path/to/resized/image.jpg');
$work = new ImgResizer('path/to/original/image.jpg');
$work -> resize_const(200,150, 'path/to/resized/image.jpg');
?>

This is not my original code. I am building upon this base.

Related Posts:

Next Page »