Monday, September 14, 2009

SEO friendly URL redirection

There are couple of things that one should maintain while redirecting urls not to let the site rank fall down on the search ranks.
Lets first learn about some redirects and then we'll see how to implement them on different servers and/or environment.
  • Redirection : In the HTTP protocol used by the World Wide Web, a redirect is a response with a status code beginning with 3 that induces a browser to go to another location. The HTTP standard defines several status codes for redirection:

    • 300 multiple choices (e.g. offer different languages)
    • 301 moved permanently
    • 302 found (e.g. temporary redirect)
    • 303 see other (e.g. for results of cgi-scripts)
    • 307 temporary redirect

  • Dealing the redirection :
    • html:
    HTTP/1.1 301 Moved Permanently
    Content-Type: text/html
    Content-Length: 174

    <p>This page has moved to <a href=""></a>.</p>
    • CF : Put the following code on the Application.cfm/cfc or on the home page
    <cfheader statuscode="301" statustext="Moved Permanently" />
    <cfheader name="location" value=""; />
    <cfabort />
    • Apache server : Put the following lines on the .htaccess file
    Redirect ^oldpage.html [R=301,L]
    • php
References :

Wednesday, September 9, 2009

C# Word Counter

I don write code for long time. I wrote this program just to count an essay ;) So not a very big deal actually.
What I have practiced here :
  • Openfiledialog : How to open and select a file.
OpenFileDialog fDialog = new OpenFileDialog();
fDialog.Title = "File to read";
fDialog.Filter = "txt files|*.txt";
fDialog.InitialDirectory = @"C:\Documents and Settings\roni\Desktop\Temp";

if (fDialog.ShowDialog() == DialogResult.OK)
  • Reading a file:
StringBuilder newFile = new StringBuilder();
string filestring = File.ReadAllText(@"C:\p_keydump.txt");
filestring = filestring.Replace("\r\n", ",");
  • Count the number of words is the file.
countedWords = strText.Split(' ').Length;