Recently the major search engines have worked together to help fix one of the biggest problems in SEO, The canonical URL. With this quick fix all you need to do is add a tag to the <head> section of the page and search engines will use this as an anchor to index the page.
since it is still fairly new we don’t know how it will work in the long run and if there are any side effects such as the pagerank not transferring.
The new tag looks like this
<link rel="canonical" href="http://www.open-source-web.com/">
But nothing can be that easy, obviously with a large site you wouldn’t want to write that out for a million pages so here is the PHP code to make it work.
$thispage = "http://www.";
$thispage .= $_SERVER["SERVER_NAME"];
$thispage .= $_SERVER["PHP_SELF"];
if($_SERVER["QUERY_STRING"]){$thispage .= "?".$_SERVER["QUERY_STRING"];}
<link rel="canonical" href="<? echo $thispage;?>">
This is a good alternative to using a basic IF condition. It basically fits the whole thing on a minimal line of code.
It is anĀ easy way to compare two values and select the right one. There are a few ways to use this but the basic jist of it is to compare two values and if its is true use the first value after the question mark, or if the condition returns false use the second value.
echo $targetvar = ($somevar == "thisVar" ? "itIsTrue" : "itIsFalse");
In the example above we can set $targetvar with the condition. it will compare the first two variables with whatever you use, more then less then etc and it will choose the correct value from the two after the question mark.
With a basic redesign you probably wont have this problem but if you have rebuilt a website even with the same content if the URL’s have changed this will have a huge effect on your search engine presence as you will be starting from scratch. Your links from internal pages may not work, links from external sites wont work and you will lose your pagerank (if it ever mattered anyway.)
A good way to keep your sites listing after a redevelopment is to use a redirect. If you are using an Apache server you can use the .htaccess file to redirect.
Redirect 301 /oldpage.html /newpage.html
But some times this isnt the best way if you have to redirect hundreds of pages. The alternative is to use a header redirect in PHP. Most web based languages such as ASP or RUBY will do the same thing but with different code.
<?php
header("Location: /newpage.php",TRUE,301); to newpage.php
?>
Recent Comments