Wednesday, June 29, 2011
Redirects: Permanent 301 vs. Temporary 302
This is where redirects come in. Using the correct redirect, in most cases a permanent 301, is key to helping maintain your existing rankings, whether your site is undergoing a complete face lift, or if you simply want to move a few pages around.
While Permanent 301 Redirects are the most common there are valid situations where either 301′s or 302′s may be the most appropriate. This article will discuss what these redirects do, common and less common uses, implementation, and how to check that you have set them up correctly
1.) What are these redirects, what do they do?
Permanent 301
To summarize in a few lines, permanent 301 redirects are just as they sound. They are permanent redirects from an old URL to a new one. These redirects tell the search engines that the old location is to be removed from their index and replaced with the new location. Using 301 redirects is the most search engine friendly way to redirect traffic and engines, and far out weighs that of various JavaScript and Meta refresh redirects.
Temporary 302
Temporary 302 redirects are also as they sound; temporary. Here you are telling the search engines to read and use the content on the new page, but to keep checking the original URL first as it will ultimately be reestablished.
2.) Common and Less Common Uses
There are many special cases where you should stand back and consider which redirect to use. In nearly all situations a permanent 301 will be the answer, but sometimes a 302 just may fit the bill. Here are some examples of when to use each redirect.
A.) Permanent 301 Redirects
As noted earlier, 301 redirects are by far the most common. When using them you are telling the search engines “do not come back to this location, the page has permanently moved.”
All three search engines handle 301 redirects the same. If Site A is 301′d to Site B, then Site B will show up in the search results and Site A will ultimately be completely removed.
Page Deleted or Moved
Probably the most common use is the moving or deletion of a single page. Let’s say that you are no longer selling a specific product and therefore have no need for its page. Using a 301 redirect to send the spiders to either the next closest product, or to a relevant product list would be of far more value then having your site return a 404 error and sending users to an error page.
The same goes with pages that are simply moved. While you are probably better off keeping the page where it is, there are many valid reasons why you may need it moved, and in this case a 301 redirect is essential to keep both the search engines, and your site users (who may have bookmarked this old page) happy.
New Top Level Domain
If you are thinking about changing your main domain name, don’t do it. If you find that there is just no way around it, and that the change is essential, 301 redirects are your answer.
By using a 301 redirect to send traffic from your old site to your new site you can help ensure that ranking damage will be minimal. Without a 301 redirect your new site will be a completely from scratch endeavor with years of hard work down the drain and any historic profile that a search engine has created will not be carried over to the new site.
WWW vs Non-WWW
This is now one of the most common uses of a 301 redirect when used in combination with Mod Rewrites. Essentially by using a permanent 301 redirect to send traffic destined to the non www version of your site (site.com) to the www version (www.site.com) you can focus the strength and prevent page rank split, giving your site’s home page (and internal pages) a nice little boost.
For more information on this specific form of redirect, please see:
How to 301 Redirect Non-WWW to WWW URL’s.
Duplicate Pages
More often than not you will find websites with valid multiple home page URL’s all which serve up the same identical page. This is most common with two versions of the home page such as: www.site.com and www.site.com/index.html.
The first step is to update all your home page links to ensure that only non-index.html version is referenced. Should you happen to miss any home page links, and to direct these /index.html pages to the right place, adding the 301 redirect will ensure that you are not splitting the page value.
Old Domains
If you find yourself with multiple websites and one or more of them are completely outdated, but still relevant and you have no chance of revitalizing it, you may want to consider using a 301 redirect to send traffic and engines to your current site.
By redirecting all internal pages of the old site to the most relevant internal pages of your new site, you will not only ensure that site visitors reach the proper updated content, but that any pre-existing rankings, link value, and other search engine goodness is transferred over to the new, active website.
Note: If you find yourself in the unusual situation of having dozens, or even hundreds of old websites, do not 301 all of them at the same time, you could likely be flagged as a spammer and endure penalties or a possible banning. If this is the case, just redirect a few of your sites that happen to have the most to offer in terms of rankings and traffic.
Rewriting confusing URL strings via Mod Rewrite
Lets say that you have a site with long confusing URL strings for all internal pages. These days the major search engines do a much better job of indexing these obscure file locations, but it is still in your best interest to redirect them to a friendlier, cleaner URL. To do this you can use Mod Rewrites which utilize 301 redirects to turn this:
www.site.com/categories/pageid?brand=348H&model=8889KHl&color=554hY
Into this:
www.site.com/bmw/650/white/
This URL is not only far more friendly to human visitors, it adds a higher level of relevance for the search engines and is easy to index.
(For the record, no, I do not own a white BMW 650, but who wouldn’t want one?)
B.) Temporary 302 Redirects
The practical use of a 302 redirect is really quite limited. In most cases a 301 redirect is the correct choice; however, there are always exceptions. If you find yourself in the position where a 301 redirect just won’t do, here are a few situations where the 302 may be a better choice.
Temporarily Moving a Page
This is the main reason this 302 redirect exists, but you have to also ask yourself, have you ever temporarily moved a page? If the time comes where you need to relocate a page on a temporary basis, with the ultimate final destination of the page being at the original location, then you would want to use the 302 redirect.
Home Page Redirect
Have you ever visited a websites home page only to find that you have been redirected to some obscure URL string like www.site.com/home/redir/pageinfo?id=23498874&g=34, but in actuality it is still their home page?
There are many cases where various dynamic sites or content management systems choose to rewrite the home page using some lengthy string of variables. The best fix for this is to use a mod-rewrite to change the messy URL into a simple www.site.com. Sometimes however, mod-rewrites may not work due to various server constraints, in which case, using a 302 redirect may be the answer.
By redirecting the home page of your site using a 302 redirect to this longer, more obscure URL, you essentially are telling the engines to continue using the shorter, original URL, but index and rank based on the content of the longer version.
In doing so you will not only clean up the display URL in any search engine rankings, but you will also help retain value from any links pointing into your home page from outside sources, ultimately helping to improve your overall search engine rankings.
Special Promotions
Let’s say you have decided to create a special promotion for a product page on your site. You have toyed with the idea of changing the original product page but have decided against it, and instead created a new promotional page.
While the promotional page is live, use a 302 redirect to temporarily send traffic intended for the product, over to the promotional page, you can then easily remove the 302 redirect once the promotion is over and the original page will come back into play.
302 Hijack
Important Note: We do NOT recommend attempting this, although if you do, you are likely to only harm yourself as this black-hat trick no longer works.
Not too long ago the spammers did what they are good at and found a way to abuse the system, in this case, the 302 redirect.
It was possible to use these 302 redirects to hijack rankings and traffic from another unsuspecting site. How did they do it?
Hackers used the 302 redirects to send the search engines from their domain (Site A) to a page on the target domain, (Site B). Google would see this and the rankings for Site B would be ultimately transferred over to the redirecting page on Site A.
Spiders were essentially cloaked to see the 302 redirect to the page on Site B, while human visitors, arriving from the newly hijacked rankings, would either see the original page, or be directed to another page residing on Site A.
302 Hijack
Because of this vulnerability any 302′s that direct to a different top level domain are now treated as 301 redirects by the search engines. By treating these as 301 redirects it eliminates the usefulness of this technique and solves the hijacking problem – sorry spammers.
Special Circumstances
There are always exceptions to every rule and situations which result in the need for a creative solution. In the past we have had a client who found themselves in one of these situations.
When undergoing a huge redesign, a client of ours was forced to have part of their site hosted on one server, and part on another. The part of the site to be moved also had to be placed at the sub domain www1. This presented the potential problem of a huge ranking loss in the search engines which just was not acceptable.
The answer was using 302 redirects on all pages which were moved over to the www1 location. Because the sub domain is still a part of the original top level domain, this solution did not risk any possible penalties from the search engines (in regards to the 302 hijack issue), and also did not cause any problems with the effects of the alternative; a 301 redirect. In the end not only were rankings not compromised, the result of the new website actually caused an overall improvement in listings and site traffic.
This was a circumstance with a number of complicated technical issues I won’t go into, but the end result was success, with much thanks to a few 302 redirects.
3.) How to Implement:
The focus of this article is about understanding the difference between these two redirects and which one is right for you. If you need help on the implementation of these redirects visit our tutorials found at:
How to Redirect an Old Domain to a New Domain
How to Redirect Non-WWW to WWW URL’s
4.) How to Check:
Not sure if you have implemented your redirects correctly? There is a fast and easy check you can do to find out.
Let’s say you are redirecting page A to page B. The obvious way to check is to try loading page A and see what comes up in your browser, but, if you have set up the wrong redirect, to the naked eye it may appear that all is correct.
To ensure that the correct status code is being utilized, use a “header checker” tool, enter the URL for the page to be redirected, and see what comes up. Finding a tool to do this is as simple as searching in Google, but to make things even easier see our HTTP Header Checker tool at StepForth.
5.) 301 / 302 Redirect Warning
Be sure to avoid redirecting large numbers of pages all to one location. This practice is commonly used by spammers and could wind up getting your site into some hot water with Google.
Spammers have been known to create thousands of pages. By generating 1or 2 links to each of these pages, and ensuring that they are spidered and indexed in Google they can then harness the power of redirects to boost site rankings. By taking thousands of pages and redirecting them all to one main page, you would essentially increase the value of the target page and transfer much of the link popularity and boost search engine rankings.
Google is onto this. If you try this, you will likely end up banned, or at least penalized. That said, there may be legitimate reasons why you would drive multiple pages via 301s to another page on your site. If this is the case, be careful so you do not wind up being flagged as spam.
6.) Summary
If your site is in need of a redirect, be sure to use the appropriate one for your situation. Correct use of these redirects can be your best friend when it comes to retaining search engine rankings, and your worst enemy if used incorrectly. There are many situations which may not be covered in this article, but hopefully you now have the information to make an informed decision on which of these two redirects is right for you.
REFERENCES
http://www.stepforth.com/blog/2008/redirects-permanent-301-vs-temporary-302/
Old domain to new domain permanent redirection
Why to redirect domain name?
When webhost is changed (moving site), there is no problem to point domain to new server, just changing DNS. When new domain must replace old domain, then could be a problem with search engines. Two domains leading to one site, it means duplicate content, and duplicate content for search engines is not acceptable, both your domains could be penalized or, worse, banned from search engine listing.
To avoid duplicate content penalty, you need to "tell" search engine spider, that your site is moved on new domain, (i.e. you need to use redirect from old domain to new).
Instead of old way with redirection pages, better is to use a permanent (301) redirection.
Simple way to do that is to use htaccess redirection - mod rewrite (apache server)
Case One: old domain to new domain - same hosting account
New domain to replace primary domain? You can't do that. Primary (main) domain is connected with your hosting account, and all add-on and parked (alias) domains are connected with your main domain. If hosting is good, and you want to keep it, you can contact support, they can do that. So, old domain could be parked, and new domain set as primary domain (account moved).
Anyway, if you wish to try, you can set new domain as "main domain", there are two ways:
Using parked domain as main domain
Parked domain (alias) is pointing to root (only if parked on your account), what means, it is the same as main domain. It could be used as "main domain" on your account, if traffic from your old domain is redirected (permanent redirect). It is not problem, but, you still need to keep your old domain, it is connected with your account, and if it is removed (or expired), all other domains (parked, ad-ons) will disappear. So, keep your primary (old) domain in good health.
In this case (alias as main domain), it is not neccessary to move any page from your site, but it is neccessary to remove any instance of old domain from page. If you are using relative linking (without full url), you don't need to change anything. In this example below, we are redirecting our primary (old) domain to new (parked, alias) domain.
#Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.olddomain.com$[OR]
RewriteCond %{HTTP_HOST} ^olddomain.com$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
Now, with this setup, every request for olddomain.com/page.html is permanently redirected (301) to newdomain.com/page.html, About htaccess, and how to add this code above, see on bottom.
There is one problem with this setup. If your stats or logs are on olddomain.com/stats/, you need to disable redirection (uploading old htaccess) at that moment. Due to redirection, your stats directory is "moved" to newdomain.com/stats/,and you will get login screen again.
Using Add-on domain as main domain
Difference from parked domain (alias) is that add-on domain is pointed to subdirectory of main (primary) domain, (i.e. addondomain.com is pointing to maindomain.com/addondomain/), while alias is pointing to root. In this case, we need to move (copy) all files to /addondomain/ directory of main domain and add redirection from root to /addondomain/.
Code is the same as above for parked page, just be sure that everything is working on add-on domain before old domain is redirected.
Anyway, you should ask your hosting support is this above possible. You can test redirection to check is it working, but not all servers are the same, so, first ask support.
Case 2 (best): Old domain to new domain - different accounts
This is the best way to change domain name. Set up new account, host new domain on that account, test if everything is working, and add redirection from old domain (account). Keep old domain and account for a few months, or for a year, leaving redirection on place.
When you are sure that new domain is indexed on search engines, and google PR updated for new domain, and there is no links to old domain, and redirected visitors, you can do with old domain and account what you wish.
Sure, htaccess code (directives) is the same as above.
Subdomain to new domain redirection
Say that you have popular site on subdomain, and wish to move to the new domain on other account. Just use code below.
#Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite.hosting.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.hosting.com$
RewriteRule (.*)$ http://www.yournewdomain.com/$1 [R=301,L]
That code could be used if you have account without domain (your account is connected with subdomain.hostingcompany.com), just add new domain to the same account, and use above redirect.
Non WWW to WWW version redirection
Believe or not, there are still sites you cannot reach without using www in domain name. That is server configuration "problem", but what if you find that your site is indexed with two "domain names", with www.yoursite.com and yoursite.com. For search engines, these are still two different sites with the same content. This happens when your link partners are using version without WWW. Search engine spiders are following those links, and in that case your site is indexed without WWW. Although you can check on YAHOO Site Explorer who is linked to your site and what version of domain name they are using, it is better to add redirection to WWW version. Working example, tested.
Uncomment first line if you have any problem.
#Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^yoursite.com
RewriteRule ^(.*) http://www.yoursite.com/$1 [R=301,L]
WWW to NON WWW version redirection
If you prefer non WWW version of domain name, code is below:
#Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^www.yoursite.com
RewriteRule ^(.*) http://yoursite.com/$1 [R=301,L]
To test it, just add www. in front of domain name in browser address bar, and you will be redirected to non WWW version.
One version of domain name will boost your Google PR.
Other examples of domain redirection
All pages from old domain to main page (root) of new domain:
redirect 301 / http://www.newdomain.com
More examples soon...
Problems?
Whatever example you wish to use, don't forget two things. Htaccess is a text file, it must be uploaded in ASCII (text) mode, not binary. It will be good to keep it offline with .txt extension, to be sure that will be uploaded in ASCII mode. Don't forget to rename it to .htaccess after upload. Second, always test it.
To avoid any interruption during testing, keep two versions of htaccess, i.e. htaccess_redir.txt and htaccess_original.txt. Upload htacces_redir.txt, rename it to .htaccess, and with opened FTP program, test domain name redirection in browser. If it is not working (server error 500), upload original file back (htaccess_original.txt) or edit and try again.
Use some online header checker (or check in website log) to confirm that server response is 301 (moved permanently). AND, do not promote new domain (if content is the same) before redirection from old domain is on place.
Search engines and 301 redirection - example
In recent experiment (Feb 2007) main domain was redirected to alias domain (same account - IP). That site is small (30 pages), it was easy to track indexing under new domain. So, month later, here is situation:
Google - new domain indexed, old domain deindexed, rank lowered (domain is new) PR 0 (3 before)
Yahoo - new domain indexed, old domain - a few pages left, indexed under both domains, rank lowered
MSN - No sign of new domain, all pages still indexed under old domain, cache shows redirect (document moved here)
What about traffic from search engines? If you are redirecting old domain to new domain, your search engine position will change. Not only due to different domain name (keyword), other factors are involved too. One month is small time frame to get things on place again. When you are sure that pages are indexed under new domain, replace/edit/ask links from other sites.
Update May 2007 : After last Google PR update, new domain has PR 2 , all pages indexed, old domain could not be found. For PR 2, we can talk about good internal linking, not that PR is transferred to new domain. New domain is new domain.
YAHOO: Old domain removed, new domain indexed. Pages are slowly getting positions where they were before, under old domain.
MSN is still waiting for something. New domain still not included in index, and main page (only that page) is still indexed under old domain. According to above, I am not sure how MSN spider is handling with 301 redirection.
Update Jun 2007 : End of experiment, no success. While google has all pages indexed under new domain, Yahoo don't want to listen. Main page and a few others are again indexed under old domain (redirection was on place all the time.). MSN still refuse to index new domain, keeping main page indexed under old domain. Since many links are still pointing to the old domain, now the new domain is redirected back to the old domain. New domain AND new hosting account is still the best solution. This example is from 2007, it exist possibility that, at time when you reading this, things are changed, even then, be carefull.
Moving site from free hosting to new domain
This is not a permanent redirection, here is META tag used to redirect old page to the new page on new domain. So, if you still have an old site hosted on "free" hosting, and want to move that site to new domain, make and upload (different) page with the same name, add redirection META tag with 10 - 15 seconds, add page moved, bla, bla... in body, with link to newdomain.com/samepage.html, and your new site will be indexed fast. Maybe will a problem with duplicate content for the first time, but that will disappear after search engine database update. Old site will remain in index, so you can use it to to get other new site indexed faster, or add some other content there. Google "page moved" or "site moved", and you will see some examples how to do this kind of redirection.
Using this "redirection" new site (domain) was indexed from Google and Yahoo fast, but two months later, domain still could not be found using MSN search (although spidered).
Update: It is fully indexed after three months.
BASE HREF tag and search engines
Base href META tag is useful when you are using relative linking on site (i.e. ../index.html instead of http://domain.com/index.html). When that tag is added to pages on new domain, it helps search engine spiders to determine real website domain.
So, it will not hurt when it is used in combination with domain redirection. Include domain version (with or without www) and page:
<base href="http://www.yourdomain.com/yourpage.html">
For main page (or subdirectory index page) could be added without page name (don't forget slash on the end):
<base href="http://www.yourdomain.com/">
Related:
Add more domains to one hosting account example
Hide affiliate links using htaccess
http://www.affiliatebeginnersguide.com/domains/redirection.html
Tuesday, December 7, 2010
Let's make the web faster Tools and downloads
From Google
Web page analysis
Page Speed -
Open source Firefox/Firebug Add-on that evaluates the performance of web pages and gives suggestions for improvement.
Chrome Developer Tools -
Tools included in Google Chrome that let you edit, debug, and monitor CSS, HTML, and JavaScript live in any web page. You can also use them to optimize web page performance by profiling CPU and memory usage.
Speed Tracer -
Google Chrome extension that helps you debug performance problems with AJAX applications.
Resource Optimization
Closure Compiler -
Optimize the speed and size of your JavaScript.
WebP -
Reduce image file sizes and download times.
Development tools
Closure Tools -
Use the Closure Compiler, Closure Library, and Closure Templates to build rich web applications with JavaScript that is faster, more powerful, and more optimized.
Google Web Toolkit -
Toolkit that allows you to build rich web applications in Java, and then compile into highly optimized JavaScript.
From other developers
Development
Cuzillion -
Tool for quickly constructing web pages to see how components interact and how behavior differs across browsers, sometimes in unexpected ways. Also lets you share sample pages with others.
Hammerhead -
Firebug Add-on for measuring the load time of web pages.
OOCSS -
Development environment and framework for creating fast, reusable CSS objects and modules.
Performance benchmarking
httperf -
Tool for generating HTTP workloads and measuring web server performance, and constructing micro- and macro-level benchmarks.
mon.itor.us -
Provides a personalized Ajax dashboard interface, checks server performance and availability, generates uptime reports, tracks visitors, checks CPU, memory and other systems resources, and alerts when it detects abnormalities.
Pylot -
Open source tool for testing the performance and scalability of web services. It runs HTTP load tests, verifies server responses, and produces reports with metrics.
Wbox -
Performs various tests, including page load benchmarking, web server and web application stress testing, and verifies correct configuration of virtual domains configuration, redirects, and HTTP compression.
JavaScript profiling
dynaTrace AJAX -
Full tracing analysis of Internet Explorer 6-8 (including JavaScript, rendering, and network traffic). (Related blogpost)
PHP profiling
Xdebug -
Extension for PHP that provides profiling and code coverage analysis, as well as debugging information including stack and function traces, and memory allocation.
XHProf by Facebook -
Instrumentation-based hierarchical profiler for PHP.
Resource optimization
CSS Sprite Generator -
Generates a CSS sprite out of a number of images.
JSLint -
Tool that looks for code quality problems in JavaScript programs.
JSMin -
Filter which removes comments and unnecessary whitespace from JavaScript files.
Smush It -
Online tool that allows you to upload images for lossless compression and optimization. Provides a report of bytes saved and downloads a zip file containing the optimized versions of the files.
SpriteMe! -
Tool that determines background images to sprite, groups and sprites them, and generates resultant modified CSS.
YUI Compressor -
JavaScript minifier designed to yield a higher compression ratio than other tools.
Web debugging
Fiddler 2 -
Web debugging proxy which logs all HTTP/S traffic between your computer and the Internet. Inspect HTTP/S traffic, set breakpoints, and "fiddle" with incoming or outgoing data.
Firebug -
Firefox Add-on that lets you edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.
HttpWatch -
HTTP viewer and debugger integrated with IE and Firefox to provide HTTP/S monitoring without leaving the browser window.
Web page analysis
AOL Page Test -
Open source tool for measuring and analyzing web page performance using Internet Explorer.
BrowserMob -
Tool for website performance monitoring and alerting.
IBM Page Detailer -
Graphical tool that assesses web page performance and provides details include the timing, size, and identity of each item in a page.
IntroSpectrum -
Web-based performance monitor which simulates users using actual web browsers.
Microsoft VRTA -
Tool that visualizes web page download, identifies areas for performance improvements, and recommends solutions.
MySpace Performance Tracker -
Internet Explorer browser plugin that helps improve web page performance by capturing and measuring possible bottlenecks.
WebPagetest -
Tool that provides a waterfall of your page load performance as well as a comparison against an optimization checklist.
Yahoo! YSlow -
Firefox/Firebug Add-on that analyzes web pages and suggests ways to improve their performance, based on a set of rules for high performance web pages.
REFERENCES
Saturday, November 6, 2010
Htaccess Tricks and Tips
Introduction
Some people might not aware of the power of htaccess, I have 17 htaccess methods in this article which I have used or tested it before, and I think some of them are essential tricks and tips to protect your webserver against malicious attacks and other would able to perform simple tasks efficiently such as redirection and web server optimization.
Last but not least, if you have been looking for web hosting services, you might want to have a look at this unlimited web hosting. :)
General
The following htaccess will able to help you to achieve simple task such as redirection and web server optimization.
1. Set Timezone
Sometimes, when you using date or mktime function in php, it will show you a funny message regarding timezone. This is one of the way to solve it. Set timezone for your server. A list of supported timezone can be found here
SetEnv TZ Australia/Melbourne
2. SEO Friendly 301 Permanent Redirects
Why it's SEO friendly? Nowadays, some modern serach engine has the capability to detect 301 Permanent Redirects and update its existing record.
Redirect 301 http://www.queness.com/home http://www.queness.com/OR
Redirect 301 /home http://queness.com/
3. Skip the download dialogue
Usually when you try to download something from a web server you get a request asking whether you want to save the file or open it. To avoid that you can use the below code on your .htaccess file
AddType application/octet-stream .pdf AddType application/octet-stream .zip AddType application/octet-stream .mov
4. Skip www
One of the SEO guideline is, make sure there is only one URL pointing to your website. Therefore, you will need this to redirect all www traffic to non-ww, or the other way around.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.queness.com [NC]
RewriteRule ^(.*)$ http://queness.com/$1 [L,R=301]
ORRewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
5. Custom Error page
Create a custom error page for each of the error codes.
ErrorDocument 401 /error/401.php ErrorDocument 403 /error/403.php ErrorDocument 404 /error/404.php ErrorDocument 500 /error/500.php
6. Compress files
Optimize your website loading time by compressing files into smaller size.
# compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript
7. Cache files
File caching is another famous approach in optimizing website loading time
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$"> Header set Cache-Control "max-age=2592000" </FilesMatch>
8. Disable caching for certain file type
Well, in the other hand, you can disable caching for certain file type.
# explicitly disable caching for scripts and other dynamic files <FilesMatch ".(pl|php|cgi|spl|scgi|fcgi)$"> Header unset Cache-Control </FilesMatch>
Security
The following htaccess code will able to enhance the security level of your webserver. Hotlinking protection is pretty useful to avoid other people using images that stored in your server.
1. Hotlinking protection with .htaccess
Hate it when people stealing bandwidth from your website by using images that are hosted in your web server? Use this, you will able to prevent it from happening.
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?queness.com/.*$ [NC]
RewriteRule .(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
2. Prevent hacks
If you want to increase the security level of your website, you can chuck these few lines of codes to prevent some common hacking techniques by detecting malicious URL patterns.
RewriteEngine On
# proc/self/environ? no way!
RewriteCond %{QUERY_STRING} proc/self/environ [OR]
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
3. Block access to your .htaccess file
The following code will prevent user to access your .htaccess file. Also, you can block multiple file type as well.
# secure htaccess file <Files .htaccess> order allow,deny deny from all </Files> # prevent viewing of a specific file <Files secretfile.jpg> order allow,deny deny from all </Files> # multiple file types <FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$"> Order Allow,Deny Deny from all </FilesMatch>
4. Rename htaccess files
You can also rename your .htaccess file name to something else to prevent access.
AccessFileName htacc.ess
5. Disable directory browsing
Avoid the server from displaying directory index, or the opposite.
# disable directory browsing Options All -Indexes # enable directory browsing Options All +Indexes
6. Change default Index page
You can change the default page index.html, index.php or index.htm to something else.
DirectoryIndex business.html
7. Block unwanted visitor based on referring domain
# block visitors referred from indicated domains
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_REFERER} scumbag.com [NC,OR]
RewriteCond %{HTTP_REFERER} wormhole.com [NC,OR]
RewriteRule .* - [F]
</ifModule>
8. Blocking request based on User-Agent Header
This method could save your bandwidth quota by blocking certain bots or spiders from crawling your website.
# block visitors referred from indicated domains <IfModule mod_rewrite.c> SetEnvIfNoCase ^User-Agent$ .*(craftbot|download|extract|stripper|sucker|ninja|clshttp|webspider|leacher|collector|grabber|webpictures) HTTP_SAFE_BADBOT SetEnvIfNoCase ^User-Agent$ .*(libwww-perl|aesop_com_spiderman) HTTP_SAFE_BADBOT Deny from env=HTTP_SAFE_BADBOT </ifModule>
9. Secure directories by disabling execution of scripts
# secure directory by disabling script execution AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi Options -ExecCGI
REFERENCES
http://www.queness.com/post/5421/17-useful-htaccess-tricks-and-tips
Thursday, April 15, 2010
Redirects Using Scripting for SEOs
Definitions
- 301 Redirect
- A function of a web server that redirects the visitor from the current
page or site to another page or site, while returning a response code that
says that the original page or site has been permanently moved to the
new location. Search engines like this information and will readily transfer
link popularity (and PageRank) to the new site quickly and with few issues.
They are also not as likely to cause issues with duplication filters. SEOs
like 301 redirects, and they are usually the preferred way to deal with
multiple domains pointing at one website.
- 302 Redirect
- A function of a web server that redirects the visitor from the current
page or site to another page or site, while returning a response code that
says that the original page or site has been temporarily moved to the
new location. Search engines will often interpret these as a park, and take
their time figuring out how to handle the setup. Try to avoid a 302 redirect
on your site if you can (unless it truly is only a temporary redirect), and
never use them as some form of click tracking for your outgoing links, as
they can result in a "website hijacking" under some circumstances.
- HTML tags that are written into the head section of an HTML page and
convey different kinds of information, but don't actually show on the page
as text. For example the title, description and keywords for the page. The
metatag
that matters for this document is the
meta-refresh tag. McAnerin Networks offers a
free metatag generator here.
Client Side Script (jump down)
- A client side script is a program that is processed on the client
(usually a web browser), after the information is sent to the user. Unlike
many modern web browsers, search engine spiders do not run client side
scripts - therefore they cannot be used to affect search engines except by
omission (i.e. scripts that deliberately "leave the spider behind" by
counting on the fact that browsers usually do execute the scripts). An
example of a client side script: Java Script
- A server side script is a program that is processed on the server,
before the information ever reaches the viewer's computer. Compared to a
client side script, which is processed on the client's computer. Examples of
languages commonly used as server side scripts: PHP,
JSP, ASP, ASP.NET,
PERL and Cold Fusion.
- The PHP Hypertext Preprocessor (PHP) is an open source server side
programming language extensively used for web scripts and to process data
passed via the CGI. PHP can be written as scripts that reside on the server
and may produce HTML output that downloads to the web browser.
Alternatively, PHP can be embedded within HTML pages that are then saved
with a .php file extension. The PHP sections of the page are then parsed by
the PHP engine on the server and the PHP code stripped out before the page
is downloaded to the web browser. More PHP
Information.
- Practical Extraction and Reporting Language (PERL) is an open source
server side programming language extensively used for web scripts and to
process data passed via the CGI. Perl scripts are not embedded within HTML
pages and do not download to the web browser but reside on the server. They
execute by being triggered from commands within HTML pages or other scripts
and may produce HTML output that does download to the web browser.
More Perl Information
- Java Server Page (JSP) is a technology for controlling the content or
appearance of Web pages through the use of a java servlet, small programs
that are specified in the Web page and run on the Web server to modify the
Web page before it is sent to the user who requested it. Sun Microsystems,
the developer of Java, also refers to the JSP technology as the Servlet
application program interface (API). JSP is comparable to Microsoft's Active
Server Page (ASP ) technology. More JSP
Information - ASP
- Active Server Pages. A specification that enables Web pages to be
dynamically created using HTML, scripts, and reusable ActiveX server
components.
VBScript and JScript are the most common scripting languages used for ASP. - ASP.NET
- A set of web development technologies marketed by Microsoft. Programmers
can use it to build dynamic web sites, web applications and XML web
services. It is part of Microsoft's .NET platform and is the successor to
Microsoft's Active Server Pages (ASP) technology.
Although you can use VBScript and JScript with ASP.NET, the standard is
C# - ColdFusion
- ColdFusion is a tag-based, middleware programming language used chiefly
for writing web-based applications. The language was created by JJ Allaire
and his brother Jeremy Allaire, but the product is currently owned by
Macromedia (to be soon acquired by Adobe).
More Information on
ColdFusion. - JavaScript
- JavaScript is a script language - a system of programming codes, created
by Netscape, that can be embedded into the HTML of a web page to add
functionality. JavaScript should not be confused with the Java programming
language. More Information on
Javascript.
- C# ("C Sharp")
- An object-oriented programming language developed by Microsoft as part
of their .NET initiative. Microsoft based C# on C++ and Java. C# was
designed as a language that would provide a balance of C++ with rapid
development, Visual Basic, Delphi, and Java.
More Information about C#
Detailed Information
Overview
The problem with using scripts for redirection is that search engines don't
execute them. This means that in order for them to work they need to be executed
on the server the when the page is called but before the search engine receives
it. There is only one exception to this and I'll get into it in a moment.
In general, since the execution of the script and the redirection happens
before the page goes to the spider, you can use any scripting language you want,
as long as the server executes it and the language itself is capable of
redirecting and responding with a status code like 301 or 302.
In general, a redirect that does not specify a 301 is treated as a 302, so in
order to do a proper 301, you need to be able to specify the status code in the
language of your choice. There are exceptions to this, but that's the general
behavior.
301 Redirect Script Code Examples
Client Side Redirects
There are two common types of client side redirects - meta-refresh and
JavaScript, and only meta-refresh actually works to redirect a search engine.
However, as you are about to see, it doesn't do a very good job. In general,
client side redirects are a bad idea and should be avoided if possible.
Meta Refresh Redirect (Not The Best
Choice)
Let's start with a bad example. It's also a very, very common example, so you
need to know about it. There is an HTML tag called the meta refresh that
can do redirects that search engines can detect and react to. This is the one
exception to the idea that client side scripts and tags don't affect search
engines. They usually look at this one.
The question is, after they look at it, how do they handle it? This is a very
important issue. For one thing, webmasters have been using this for years in
good faith, and if a search engine fails to understand it then the result would
be a lot of very good sites not being handled properly.
So a search engine needs to deal with it. Most search engines assume that a
refresh that's faster than the time it would take the average page to load fully
is intended act like a server redirect, whereas if the refresh is set high
enough for the user to see it and update their bookmarks, that the intent was to
have the user fix their bookmarks, not for the server to fix it for them. At
this point the refresh is more of a courtesy than an instruction. Therefore
search engines typically only worry about fast refreshes.
Now, they appear to treat a fast meta refresh as a 302, and life is much
better for everyone involved. I'm not aware of any official statements on how
they handle meta refresh, so this information comes from word-of-mouth and
testing. Since it's handled as a 302, it's not the preferred type of redirect
for SEO purposes.
Yahoo, to their immense credit, has actually outlined how they handle this.
If a meta redirect is set to 0 seconds, then it will be treated as a 301
redirect. If it is greater than 1 second, it's treated as a 302 redirect.
Frankly, I consider this to be an excellent way to handle it.
MSN Search says "Adding a meta redirect tag to your page header does not
remove your original page from the MSN Search index; however, it will redirect
visitors to your new site. " I read this to mean that they treat it as a 302
redirect. Since a 302 is considered temporary, the original page is kept in the
index.
ASK apparently treats a meta-refresh of 0 as a 302, where it retrieves the
target page in place of the source page, but keeps the source page reference
until it figures out what is going on.
So basically, all 4 major search engines handle the meta-refresh differently
- I strongly recommend NOT using it if you have any choice. If you have to, you
are best assuming that a meta-refresh of 0 will work most consistently, and will
probably be treated as a 302 by everyone except Yahoo, who will treat is as a
301.
This goes against the "conventional wisdom" that a meta-refresh will result
in a ban or penalty. Not true. It will result in a 302 - which may look like a
penalty under some circumstances. 302's can be bad news since the target content
is treated as belonging to the source page, which can result in hijacks,
duplication issues, and numerous other problems.
I don't recommend it, but it can work as a method of last resort. Caveat
Emptor.
Meta Refresh Example (Not The Best Choice)
<META HTTP-EQUIV=Refresh CONTENT="0;
URL=http://www.newdomain.com">
JavaScript Redirect (Not Recommended At All)
JavaScript is the second type of common client side redirect. Unlike the
meta-refresh tag, a search engine will ignore a JavaScript redirect and stay
on the page.
Some people have decided that they could use this behavior to spam the search
engines, by stuffing keywords on a page and then using a fast JavaScript
redirect to move people on to the next page while allowing the spider to stay
and index the spam page.
Google figured out how to detect this tactic in the summer of 2004 and as a
result a LOT of websites lost rankings, resulting in at least one infamous SEO
firm getting a class action lawsuit started against them, as well as making them
look really bad.
In short, JavaScript redirects do not work for search engines, and using them
can possibly get you banned from a search engine, depending on the
circumstances.
Never use a JavaScript redirect on a page or domain you want to rank with
search engines.
The only reason I included them on this page is to serve as a warning. There
are some times you could use them on pages that are not search engine
accessible, such as certain shopping cart systems and so forth, but in general,
you are best off avoiding them.
Javascript Redirect Example (Not Recommended)
<script type="text/javascript">
<!--
window.location = "http://www.newdomain.com/"
//-->
</script>
or
<body onLoad="setTimeout(location.href='http://xxx', '0')"
>
I cannot stress enough that this method is NOT
recommended.
It has the net effect of showing humans and search engines 2 different things
- not a good start to long term results. Basically, it's risky.
Server-Side Redirects
Servers do not automatically go though every webpage they serve out and look
for scripts to run. They only look inside files that they know may have server
side scripting in them. This saves overhead for the server, and is more
efficient. Traditionally, files ending in .htm and .html are considered static
and therefore most servers will not attempt to execute them. You can force them
to be recognized as dynamic, but in general this is not done.
When a dynamic page is called from a server, the server looks in the page
first, before sending it to the user. It will then execute all the scripts it
recognises as scripts it should execute, then sends the results to the
user. This means that a dynamic page can look very different on the server than
it does when it finally reaches the user. It's common for certain CMS systems to
only have one page in them, and that page's content is controlled by the
variables sent to it. This is one of the reasons why search engines will
distrust pages with a lot of variables.
In order to execute a server side script, the server must be set to process
the page type it's on, and the script must be present on the page (usually in
the header or at the very top of the page)
PHP 301 Redirect Example
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/newdir/newpage.htm");
exit();
ASP 301 Redirect Example (VBScript)
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.newdomain.com/newdir/newpage.asp"
response.end
%>
ASP 301 Redirect Example (JScript)
function PermanentRedirect(strDestinationUri) {
Response.Clear();
Response.Status = 301;
Response.AddHeader("Location", strDestinationUri);
Response.Flush();
Response.End();
}
Note:
“strDestinationUri” should be an absolute URI for maximum client
compatibility. The function assumes that “Response.Buffer = true;” has been set
at some point prior to invoking the function and will error if hasn't (this is
the default configuration for IIS5 and above).
ASP .NET 301 Redirect Example (C#)
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com/");
}
</script>
Cold Fusion 301 Redirect Example (CFM)
Simply add this code to your ColdFusion page:
<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com/">
JSP / JAVA 301 Redirect Example
Simply add this code to your page or script:
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>
CGI / Perl 301 Redirect Example Code
Perl is different from the above examples because it doesn't go on a page
at all. It's actually a script that is called (usually from the cgi-bin).
"Pages" typically look like "pages.cgi" and are called as if they were scripts,
not web pages.
#! /usr/bin/perl
use cgi;
my $q = cgi->new();
print $q->redirect(
-location => 'http://www.newsite.com/newpage.cgi',
-status => 301,
);
Processing Static Pages as if they were Dynamic
Sometimes you will want to do redirects on pages that are standard static web
pages (ie htm or html). This is especially common when you are trying to switch
from an old static system to a newer dynamic one. The problem is that since
search engines don't execute scripts, redirection scripts won't work for a
search engine in a static page. What to do?
Well, there is a fix. More like a kludge. But it works. What you do is tell
the webserver that pages with the extension .htm (and/ or .html) are actually
dynamic and should be treated as if they were dynamic pages. This will slightly
increase the load on your server (since all .htm pages will be processed before
being rendered) but it's very slight and you probably won't notice it.
It would be no different of a load than if you just switched all your pages
over to dynamic anyway.
Processing .html Pages as if they were .php in Apache
You can force all *.htm pages to be parsed by the php interpreter with an
.htaccess directive:
AddType application/x-httpd-php .html
Make appropriate adjustments if it's *.htm documents you want processed:
AddType application/x-httpd-php .htm
Processing .htm Pages as if they were .asp in IIS
In the Internet Services Manager, go to the "Home Directory" tab of your
website properties and click the "Configuration" button. On the "App Mappings"
tab of that pop-up, you can control how files are processed. You want to set up
a new mapping for the HTM extension that looks just like the ASP mapping. You
can also do this for HTML files, if you use them.
Some systems are set up differently from mine - just look at whatever the
settings are for your ASP pages and duplicate them for HTM pages.
Conclusion
Scripting redirection can accomplish a lot, and if it's server-side you are
usually pretty safe regarding search engines following it. In general, it takes
less overhead and is easier to use webserver redirection using either
Apache or
IIS. However, redirection with scripting is a legitimate technique for
people without full control over their server, or who have some very specific
scenarios requiring redirection that are not supported by the webserver
directly.
REFERENCE
http://www.mcanerin.com/EN/articles/301-redirect-scripting.asp
IIS Redirects - 301 , 302
Microsoft's Internet Information Server ( MS IIS ) is very different from
Apache, and you need to handle redirects on it differently.
Although you can use the popular FrontPage web development software with
Apache + FP extensions, most people who use FrontPage prefer to use IIS. Also,
Microsoft's .NET and ASP development platforms usually work best on MS IIS (no
surprise there).
Definitions for Terms used in
this Article
Detailed Information
Overview
What you are trying to accomplish here is to have one resource (either a page
or an entire site) redirect a visitor to a completely different page or site,
and while doing so tell the visitor's browser that the redirect is either
permanent (301) or temporary (302).
Therefore you need to do three things:
- Have 2 resources - one source page or website, and one destination page
or website. - When an attempt to access the source resource is made, IIS transfers the
visitor to the destination instead. - During the transfer, IIS reports to the visitor that a redirect is
happening and it's either temporary or permanent.
The good news is that IIS has always supported this, and you can use it's
control panel to make the redirect.
Administrator Mode - Redirecting a Domain
If you can log into the Windows 2000 (or higher) server and access the
desktop, then choose:
Start > Programs > Administrative Tools > Internet Services Manager
Now choose the server running the site you want to forward. Remember you need
2 sites - one to forward FROM and one to forward TO. These can be on the same,
or separate servers.
Right click on the site you want to redirect FROM and choose Properties > Home
Directory
You will see the following:
The default is the first choice, "A directory located on this computer". Change
it to "A redirection to a URL" and type in the new URL.
If you want it to be a 301, then be sure to check ON
the choice for "A permanent redirection for this resource". If you want it to be
a 302, leave the choice checked OFF.
Administrator Mode - Redirecting an Individual Page
If you can log into the Windows 2000 (or higher) server and access the
desktop, then choose:
Start > Programs > Administrative Tools > Internet Services Manager
Now choose the server running the site you want to forward. Choose the site
with the webpage you want to forward in it, then right click on the it and
choose "Properties".
You will see the following:
The default is the first choice, "The designated file". Change it to "A
redirection to a URL" and type in the new URL.
If you want it to be a 301, then be sure to check ON
the choice for "A permanent redirection for this resource". If you want it to be
a 302, leave the choice checked OFF.
If you don't control the IIS server, ask the admin to do the above. Done.
Passing on Variables or a Query String During IIS Redirects
Let's say that you want to pass on some variables, for example, you wanted to
redirect an ASP site that accepted arguments for some pages and pass those same
arguments on to the same pages at the new site.
In this case, in the "Redirect to:" box, enter the domain you wish to move to
(no trailing slash), plus $S$Q .
For example:
http://www.newdomain.com$S$Q
Next, check the options that state the client will be sent to "The exact
URL entered above", as well as "A permanent redirection for this resource"
(if you want it to be a 301). Done.
What does this $S$Q do? These are tags that IIS will automatically replace -
$S will be replaced with the subdirectory location (such as /shopping/cart.aspx)
and $Q will be replaced with the querystring (such as ?id=Blue).
| Server Variable | Function | Example |
| $P | Passes parameters that were passed to the URL to the new URL. | If the request contains parameters such as http://www.oldsite.com/cart.asp?id=Blue , then $P would represent all the values after the question mark in the URL, example $P would equal id=Blue (no question mark). |
| $Q | Passes the parameters including the question mark. | This is the same as $P but includes the question mark or query string. So $P would equal ?id=Blue |
| $S | Passes the matching suffix of the URL to the new URL. | If the request is for http://www.oldsite.com/shopping/cart.asp, then $S represents /cart.asp. If the request was for http://www.oldsite.com/shopping then the value of $S would be /shopping |
| $V | Removes the server name from the original request. | If the request is for http://www.oldsite.com/shopping/cart.asp then $V would contain everything after the server name, eg: /shopping/cart.asp. |
| * | Wildcard symbol used for replacement. | Let's say you want to redirect all requests for html pages to a single asp page - you could do so in the following way: *;*.htm;page.asp |
This works for both Site Redirects and Individual Page Redirects.
Common Scenarios
I Just Want To Switch Domains!
This is actually pretty straightforward. You can tweak things to get exactly
what you need with the variables above, but the following will work for the most
common setups:
http://www.newdomain.com$V$Q
Do NOT add a trailing slash "/" at the end of the domain name!
Make sure you check:
- The exact URL entered above
- A permanent redirection for this resource
Done! This will send everything after the old domain name to the new domain
name, including variables. You need to do is make sure that the new website is
set up exactly the same as the old one and that all you are doing is changing
domain names.
Non-WWW to WWW Redirect for IIS
When you set up a site in IIS, usually you set up the site with a domain name
and add the domain name with both versions, www and non-www, to the host headers
for the account. This creates a potential duplication issue, though.
The better way to do this is to actually create 2 accounts - one with the www
version and one without. Then you put the website in your preferred version and
a single page in the other. Normally, you would then treat this as if you were
switching domains (above), with the 2 domains being the www and the non-www
versions.
Another method, for those that don't have direct access to the
control panel (common with many ISP's/ hosts), is to put your entire website in the www account and then a
single page in the non-www account. Then you would put the following code in the
default page in the account with the single page (i.e. the one you are redirecting):
< %@ Language=VBScript %>
< %
Response.Status="301 Moved Permanently"
Response.AddHeader "Location",
http://www.example.com
%>
What about Parameters?
If you do a non-www to www redirect for MS Internet Information Services
(IIS) and have parameters that need to be passed on, then do the following
(Thanks to Chris Hirst for testing
this):
- Do the above non-WWW to WWW redirect
- Make double sure that you do NOT have a trailing slash at the end of the
domain (http://www.newdomain.com$V$Q, NOT http://www.newdomain.com/$V$Q) - As with all these redirects, make sure that you check "The exact URL
entered above"
Don't Have Administrator or Desktop Access?
If possible, ask the Administrator for the site to perform the above steps.
If you can't, you need to use ASP or .NET scripting on-page to do redirects.
Conclusion
IIS is a powerful and easy to use web hosting platform. If you have access to
the Admin panel you can accomplish basic tasks (like simple redirection) easily
and quickly. If you don't have access (and don't want to switch hosts) then you
will have to use redirection scripting to accomplish this. You'll learn more
about that in the Redirects Using On-Page
Scripting and Headers section.
REFERENCE
A Short Case Study on Redirects: 301s vs. 302s
When I moved to this site a couple of months ago and redirected the old blog to this one, I experienced the joys and sorrows that we all do when we move sites. I was redirecting at several levels. From the .htaccess file of the old site, I was doing a site-wide redirect. From the .htaccess file of the new site, I was redirecting from the old URL pattern to the new one (and from the non-www version to the www version). Wordpress itself was also redirecting, for instance, from the version of the URL without the slash to the version with it. Within .htaccess, some redirects use RedirectMatch, others use Redirect, and others are really URL rewrites using mod_rewrite.
I also redirected my feed using .htaccess and Feedburner, and am still sorting out how (and if you really can) redirect and consolidate (even if you’re using MyBrand).
There’s a lot going on and I intentionally unleashed it using all kinds of variations to see what would happen. For you. Surely someone will send me a cookie.
The difference between 301s and 302s
I have a whole set of notes that I’m writing up on all the different redirection options and what the pitfalls are, but for now, I wanted to illustrate the difference between a 301 and a 302. I am asked this a lot (“does it really make a difference?). It can get confusing, because although search engines say to use a 301 when moving a site (or page), server software tends to use a 302 as the default when you implement a generic redirect (without specifying if it should be a 301 or 302).
Some of the redirects for my site move were initially implemented as 302s and others as 301s, so I could see how things worked in real time.
A 302 is a “temporary” redirect
Search engines tend to interpret a 302 as an instruction to index the old URL but the new content. It keeps the old URL because the server has said that the new one is only “temporary”. You can see that here with a Google search for my name. As you can see, the URL is for the old site, but the title and description in the search result are from the new one.
A 301 is a “permanent” redirect
Search engines interpret a 301as an instruction to replace the old URL with the new one. As you can see, once I changed the redirect to 301, the new URL showed up in the place of the old one.
The new URL is ranking in the same location for the query [vanessa] as the old URL was, which implies that the links and anchor text that pointed to the old URL are now being transferred to the new URL. In addition, you might notice that the URL I’m redirecting my old home page to (www.ninebyblue.com/blog/) has a toolbar PageRank of 6, while the home page of this site (www.ninebyblue.com) has a toolbar PageRank of 4, so at least in terms of visible toolbar PageRank, that credit is passed via the 301 as well.
Should you use a 301 or 302?
As you can see, for a permanent site (or page) move (and to consolidate duplicate pages), a 301 is the way to go, and you should check with the details of your implementation to make sure that your redirect really is happening via 301.
REFERENCE
http://www.ninebyblue.com/blog/a-short-case-study-on-redirects-301s-vs-302s/
Wednesday, April 14, 2010
seo-issues-with-moving-a-domain/
The problem
Let's say you own a domain like bestsitesof2006.com - it's now 2007 and you realise that your purchase of said domain may not have been the best long-term choice.
You want to start using your great brand-new domain bestsitesof2007.com (not the quickest are you?).
bestsitesof2006.com is getting great traffic and has good pagerank, and you don't want to lose any of that.
Duplicate content, link juice etc
Your great rankings are currently coming from the thousands of links you have painstakingly built over the last year.
If you launch bestsitesof2007.com with exactly the same content as bestsitesof2006.com and run the 2 sites side by side, Google is going to filter out one of the sites using their duplicate content filters (which are getting much better). Google will likely filter out the less powerful of the 2 domains, namely the newest one.
At any rate, you want your link juice from bestsitesof2006.com to flow into bestsitesof2007.com so that it can rank well based on those links.
The 301 redirect
A 301 redirect is known as a permanent redirect, and should be used for permanently changing the URI of a page. This is exactly what we are doing here.
All pages from bestsitesof2006.com need to be 301 redirected to bestsitesof2007.com - this can be done sitewide, or page by page, either method is appropriate.
The GoogleBot will follow links into bestsitesof2006.com and see the 301 redirect. The old page will be removed from Google's index and the new page added instead.
By deleting and then adding, there is no issue with duplicate content as the 2 pages don't exist in Google's index at the same time.
Time delays
Moving a domain is something everyone has different experiences with. I can only report on what I have seen happen to my sites, and what people have told me.
Please don't take this information to be gospel, because it's not.
I have found that it can take a couple of weeks for Google to start deleting old pages and adding new pages, this will depend on how often Googlebot visits your site, and how authorative your domain is.
Your new homepage will be indexed first, followed by other pages on your new site.
If your new domain is newly registered, expect your rankings to take a dive for a period of weeks to months. The new domain has no authoraty whatsoever, and it takes time for the effect of the redirected links to kick in.
Loss of rankings
Yes, you did read that correctly. The method of moving a domain that I recommend can involve you getting shit rankings for up to 6 months. If your old domain has really great links and authority, then some people report no ongoing reduction in rankings.
Pagerank
Some people worry about losing PageRank when shifting a domain. Umm, yeah, you do lose all pagerank across your new site for up to 3 months. But you shouldn't worry about this, be more concerned about rankings, traffic and sales instead.
With any new domain, your pagerank is zero until Google does a quarterly toolbar update. At any rate, the toolbar does not reflect the true PageRank of the site, so it's not worth worrying about.
I generally find the PageRank of sites I move returns to normal within 3-6 months of the move (1 - 2 toolbar updates).
Updating old links
You have spent lots of time building links. Great. With the 301 redirects, the juice from these links now flows to the new site.
It's still worth approaching some of the better sites that link to you and asking them to update the link.
Cleaning up URLs
So, you are going to change every URL on your site and take a bit of a hit in the rankings, huh?
You don't want to tave to repeat this process again.
Now is a great time to clean up the URLs on your site.
eg...
bad: www.domain.com/index.php?pageid=45
bad: www.domain.com/aboutourteam.php
bad: www.domain.com/about_our_team.php
bad: www.domain.com/About-Our-Team.php
bad: www.domain.com/content/45.htm
good: www.domain.com/about-our-team.php
good: www.domain.com/about-our-team/
good: www.domain.com/about-our-team.htm
good: www.domain.com/about-our-team
good: www.domain.com/team/
If your site is static, rename all your pages so they are dash separated, lower case only, and logical.
If your site is driven by a content management system or forum package, now's a great time to go install whatever SEO plugins or modules are required to fix up the URLs. Many CMS systems such as Wordpress have free plugins that do the job nicely. Others, such a VBulletin have plugins that aren't free (VBSEO plugin), but still well worthwhile investing in.
Shameless plug:
Jojo CMS doesn't need any plugins to have nice URLs.
The bottom line
When you change a domain, you accept some risk that rankings can drop significantly for several months. This is one of the costs of rebranding, so make sure the decision makers consider this cost BEFORE deciding on the rebranding of a business.
The unpleasantness of this process is one reason why domainers will pay good money for the right domain name, and why it's better to think long-term before investing time and money into the wrong domain.
REFERENCE
http://www.ragepank.com/articles/97/seo-issues-with-moving-a-domain/
Thursday, February 11, 2010
How to Add Google Analytics to Your Blogger Blog
Grab Your Google Analytics Code Block
- Login to Google Analytics at http://google.com/analytics/. The main Settings page loads.
- Click on Add Website Profile. A form displays.
- Select Add a Profile for a New Domain.
- Enter the URL of your site or blog.
- Select your country and time zone. Click Finish.
- Analytics provides you with a code block – a swatch of HTML – to add to your site’s pages.
- Highlight the code block and then copy it by selecting Edit > Copy or Ctrl-C or Command-C.
Add the Google Analytics Code Block to Your Blogger Blog
- Login to http://www.blogger.com/. The Dashboard loads.
- Under the blog you want to add Analytics tracking to, click on Layout or Template.
- Click on Edit HTML. An editing screen for your blog template’s HTML displays. Don’t freak out. Just scroll to the bottom.
- Look for the end of the template. It’ll look like:
</div> </div>
<!– end outer-wrapper –>
(Google Analytics Code Block is going to go here!!!)
</body>
</html>
- Put your cursor right before that </body> tag.
- Paste the Google Analytics Code Block by selecting Edit > Paste, Ctrl -V or Command-V.
- Click Save Changes.
You have now added the Google Analytics Code Block to Your Blogger Blog.
Check Your Work
- To ensure that you have successfully added the Google Analytics Code Block to your Blogger blog, go back to http://google.com/analytics/.
- Next to your blog’s URL it will say either Receiving Data (you were successful) or Tracking Not Installed (something is amiss).
- If it said Tracking Not Installed, click on Check Status. Google then checks your blog for the Analytics Code Block and reports back if it find it or not.
- If not, try re-pasting the Code Block in.
REFERENCE
http://www.andywibbels.com/how-to-add-google-analytics-to-your-blogger-blog/
Monday, January 4, 2010
How to Redirect a Web Page
301 Redirect
301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It's not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it's the safest option. The code "301" is interpreted as "moved permanently".
You can Test your redirection with Search Engine Friendly Redirect Checker
Below are a Couple of methods to implement URL Redirection
IIS Redirect
- In internet services manager, right click on the file or folder you wish to redirect
- Select the radio titled "a redirection to a URL".
- Enter the redirection page
- Check "The exact url entered above" and the "A permanent redirection for this resource"
- Click on 'Apply'
ColdFusion Redirect
<.cfheader statuscode="301" statustext="Moved permanently"><.cfheader name="Location" value="http://www.new-url.com">
PHP Redirect
<?Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
ASP Redirect
<%@ Language=VBScript %><%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>
ASP .NET Redirect
<script runat="server">private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>
JSP (Java) Redirect
<%response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>
CGI PERL Redirect
$q = new CGI;print $q->redirect("http://www.new-url.com/");
Ruby on Rails Redirect
def old_actionheaders["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end
Redirect Old domain to New domain (htaccess redirect)
Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Please REPLACE www.newdomain.com in the above code with your actual domain name.
In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website.
Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
Redirect to www (htaccess redirect)
Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Please REPLACE domain.com and www.newdomain.com with your actual domain name.
Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
How to Redirect HTML
Please refer to section titled 'How to Redirect with htaccess', if your site is hosted on a Linux Server and 'IIS Redirect', if your site is hosted on a Windows Server.
Reference: http://www.webconfs.com/how-to-redirect-a-webpage.php
Wednesday, December 30, 2009
How to setup a 301 Redirect
The “301 Permanent Redirect” is the most efficient and search engine friendly method for redirecting websites. You can use it in several situations, including:
- to redirect an old website to a new address
- to setup several domains pointing to one website
- to enforce only one version of your website (www. or no-www)
- to harmonize a URL structure change
There are several ways to setup a 301 Redirect, below I will cover the most used ones:
PHP Single Page Redirect
In order to redirect a static page to a new address simply enter the code below inside the index.php file.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/page.html");
exit();
?>
PHP Canonical Redirect
The Canonical 301 Redirect will add (or remove) the www. prefixes to all the pages inside your domain. The code below redirects the visitors of the http://domain.com version to http://www.domain.com.
<?php
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$_SERVER['HTTP_HOST']
.$_SERVER['REQUEST_URI']);
}
?>
Apache .htaccess Singe Page Redirect
In order to use this method you will need to create a file named .htaccess (not supported by Windows-based hosting) and place it on the root directory of your website, then just add the code below to the file.
Redirect 301 /old/oldpage.htm /new/http://www.domain.com/newpage.htm
Apache .htaccess Canonical Redirect
Follow the same steps as before but insert the code below instead (it will redirect all the visitors accessing http://domain.com to http://www.domain.com)
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
ASP Single Page Redirect
This redirect method is used with the Active Server Pages platform.
<%
Response.Status="301 Moved Permanently"
Response.AddHeader='Location','http://www.new-url.com/'
%>
ASP Canonical Redirect
The Canonical Redirect with ASP must be located in a script that is executed in every page on the server before the page content starts.
<%
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www."
& Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("SCRIPT_NAME")
End if
%>
Reference: http://www.dailyblogtips.com/how-to-setup-a-301-redirect/
