Redirect using IIS7

by Matti Lehtinen January 20, 2010 09:27

It is essential that the same content is found only under single URL. Alias URLs should be redirected to the main URL. Otherwise you may get "duplicate content penalty" by Google which gets your site lower on search results. E.g. if you have domains www.foobar.com and www.foobar.net, you want the .net to be forwared to the .com.

On IIS 7 redirection can be made by following steps:

1. Install IIS 7 Rewrite Module (Requires Reboot!)

2. Edit web.config file of your site. The code should be put under <system.webServer> element. The following example redirects from www.foobar.net, foobar.net and foobar.com to www.foobar.com.


<rewrite>
 <rules>
 <rule name="Redirect to www.foobar.com" stopProcessing="true">
  <match url=".*" />
  <conditions logicalGrouping="MatchAny">
  <add input="{HTTP_HOST}" pattern="^foobar\.net$" />
  <add input="{HTTP_HOST}" pattern="^www\.foobar\.net$" />
  <add input="{HTTP_HOST}" pattern="^foobar\.com$" />
  </conditions>
  <action type="Redirect" url="http://www.foobar.com/{R:0}" redirectType="Permanent" />
 </rule>
 </rules>
</rewrite>

Note that redirectType should be "Permanent". This creates "301 Moved Permanently" redirection which is most SEO friendly.

Tags: , ,

General | SEO

getMonth() trap in Javascript

by Matti Lehtinen December 14, 2009 19:07

In .NET DateTime.Month returns the month as integer between 1 and 12. Corresponding thing in JavaScript is Date.getMonth() but values are from 0 to 11.

Ok, it is common to start indexing from zero but the confusing part is that JavaScript’s Date.getDate() returns values from 1 to 31 so it is not analogous to getMonth(). Be aware of that trap when playing with dates in JavaScript.

Tags:

JavaScript

Key Points from Microsoft Techdays 2009 Finland

by Matti Lehtinen March 07, 2009 21:01

Here are my key points from Techdays conference which was held in Helsinki on 5th - 6th of March:

  1. Visual Studio 2010 and .NET framework 4.0 are almost here. Get ready.
  2. ASP.NET 4.0
    • One click deployment that creates a package file (uses MSDeploy). This can be compared to .jar packages of java.
    • Support for multiple web.config files without needing to copy-paste.
    • AJAX Client Templates will change the way we are writing JavaScript.
    • ASP.NET MVC- a new alternative to Web Forms
  3. Azure Services Platform
    • Less worries about environment and scalability.
    • Note that SQL Data Services != MS SQL Server.
  4. SharePoint 2007
    • Application lifecycle must be planned carefully because there are many challenges especially with upgrading the application.
    • See patterns & practices SharePoint Guidance. It contains plenty of useful information.
    • Check Prism V2 if you are planning to use Silverlight 2.0 with SharePoint. It contains patterns and practices to develop modular, rich applications.
  5. Pex and Chess are really cool new tools which will help you to catch bugs.

TechDays videos will be available at codezone.fi.

Tags: , , , , , ,

Visual Studio | General | ASP.NET | SharePoint

Writing PHP using Visual Studio

by Matti Lehtinen February 22, 2009 11:35

I recently found an interesting Visual Studio plugin named VS.PHP. It allows you to write and debug PHP code using Visual Studio 2005 or 2008.

The home page of VS.PHP promises plenty of features like PHP 5 support, IntelliSense and debugging of PHP and JavaScript code. It was a surprise for me that all of those features really worked out of the box. I expected some hassling at least with debugger configuration but you can just create a new PHP project and hit F5. Especially the debugger integration has been implemented very well. All the common debugging features like local variables window, break points and call stack works.

slider_debugger

Intellisense of VS.PHP seems not to work perfectly yet. Sometimes it does not find anything and sometimes it even gives variables and methods of wrong class. The stability of the plugin needs some improvement too since there was some random crashing but luckily crashes do not occur very often. It is also weird that on different computers VS.PHP wants to reorder the lines of the project file. This feature causes some extra conflicts when multiple developers are working on the same project using Subversion or some other version controlling software.

VS.PHP runs PHP pages using built-in Apache web server. For debugging it uses XDebug and DBG.

The plugin costs $99.99 per developer but there is 30-day free trial available. Regardless of some problems I got positive impression about the plugin. It allows me to develop PHP using the IDE which I am most familiar with.

Summary

  • + Works out of the box
  • + Offers familiar environment for .NET developers to write PHP code
  • + Great debugging support for PHP and JavaScript
  • - Some stability problems
  • - Intellisense does not work very well

Tags: ,

Visual Studio | PHP

Better Font for Visual Studio

by Matti Lehtinen September 13, 2008 11:00

There is a much better font available for Visual Studio than Courier New which is the default font. Consolas font is created for programming environments and is more comfortable to read than Courier New. You can see the difference below:

visual studio font courier new
Courier New

 

visual studio font consolas
Consolas

Consolas Font can be downloaded from Microsoft. The installer automatically sets it to be the default font for Visual Studio.

Tags:

Visual Studio

SEO and BlogEngine.NET

by Matti Lehtinen September 03, 2008 21:48

It is important to make your blog to search engine friendly so that visitors can find to your site and you get well targeted traffic from search engines. Because of that I made some basic SEO (Search Engine Optimization) to my blog which is using BlogEngine.NET software. In addition of that I added also tracking of visitors.

Sitemap

Sitemaps are files which tells for the search engines what pages your site contains. By using sitemaps you can be sure that the search engines know all pages of your site. This does not however mean that every page gets indexed though. 

It was nice to notice that BlogEngine.NET has built-in support for sitemaps. The sitemap file is sitemap.axd. A reference to this file needs to be added to robots.txt to make search engine crawlers to be aware of it. There is already following line in that file:

#sitemap: http://example.com/sitemap.axd

That line must be uncommented (remove the # character) and the url must be changed to a correct one. For example I changed that line to:

sitemap: http://www.mattilehtinen.com/blog/sitemap.axd

After modifying robots.txt, I uploaded the sitemap also to Google Webmaster Tools to see which pages are indexed and which are not. Using of Google Webmaster Tools is not necessary if you use robots.txt but it gives some nice statistics about your site.  

URLs

URLs of BlogEngine.NET seemed to be by default in human readable format and not something like www.myblog.com?post=12345 which would be unacceptable. You want that there is keywords in your URLs because it helps search engines to know what your page is about. GET parameters should be avoided because the search engines do not understand them very well.

BlogEngine.NET automatically generates the URL from the title of the post which is nice because the URL automatically contains relevant words to your blog post. It is also possible to customize the URL of a post if required.

Titles

Titles of the post pages are autogenerated from the actual titles of the posts which is good thing. The bad thing was that BlogEngine.NET put by default the name of the blog before the post title like this:

Matti Lehtinen's Blog - Title Of My Blog Post

Instead of that I would prefer following:

Title Of My Blog Post - Matti Lehtinen's Blog

I don't want that people find my posts by using search phrase "Matti Lehtinen's Blog" because that's irrelevant. I want that the blog posts can be found by using the keywords of the posts. Google gives more value for words at the beginning of the title and that is why the title of the blog post should come before the name of the blog. Fortunately the titles can be improved by turning off the title prefixing feature from the settings tab by unchecking Prefixes the page titles with the name of the blog option. After that the page title contains only the title of the post which is much better choice.

Tracking of visitors

It is always nice to know how much visitors there is at your site so I added Google Analytics for my blog. This is easy to do. Just copy-paste your tracking script from Google Analytics to the Tracking Script text field in the settings tab. I added also my blog to FeedBurner and changed the RSS link point to the FeedBurner link from the Settings tab.

I am expecting that spam bots will find their way in the future to this blog so I installed Akismet Extension for BlogEngine.NET to help with that problem.

BlogEngine.NET is already quite search engine friendly. You don't need to make any big hacks to it if basic SEO is enough for you. I was actually positively surprised about the features of this blogging platform.

Tags: , , , ,

BlogEngine.NET | SEO

BlogEngine.NET up and running.

by Matti Lehtinen August 31, 2008 13:55

This is my first blog entry using BlogEngine.NET. At first glance it looks a great option for people like me who want .NET based blogging solution. Installation was easy and there is plenty of extensions available. A nice feature was that the blog sidebar can be edited just by dragging & dropping altough that feature seems to work only with Internet Explorer. I think I have now configured everything properly and should be able to start blogging.

This blog will be mainly about .NET development, technologies and tools. I will write about my own ideas, findings and experiences from the .NET world rather than linking to others' content. I'm a software developer myself so this blog will be more professional than personal blog. I am from Finland and not a native English speaker so please excuse my English.

Tags:

General | BlogEngine.NET

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen | Modified by Mooglegiant