Friday, April 27, 2012

Fix 5 Common SEO problems using URLRewrite module and Web.config

There are an example code used to fix top 5 common problems for SEO, to get unique urls, improve ranking on Search Engine likes Google, Bing, Yaoo

This example is run on

                    <!--Fix 5 Common SEO problems using URLRewrite module and Web.config-->
                    <rule name="No-slash to slash">
                        <match url=""/>
                        <action type="Redirect" url="" redirectType="Permanent"/>
                    <rule name="www to non-www">
                        <match url="(.*)"/>
                            <add input="{HTTP_HOST}" pattern="^example\.com$" negate="true"/>
                        <action type="Redirect" url="{R:1}" redirectType="Permanent"/>
                    <rule name="No Default.aspx" stopProcessing="true">
                        <match url="(.*?)/?Default\.aspx$"/>
                        <action type="Redirect" url="{R:1}/" redirectType="Permanent"/>
                    <rule name="No .aspx" stopProcessing="true">
                        <match url="(.*?)\.aspx$"/>
                        <action type="Redirect" url="{R:1}.html" redirectType="Permanent"/>
                    <rule name="Lower Case URLs" stopProcessing="true">
                        <match url="[A-Z]" ignoreCase="false"/>
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                            <add input="{URL}" pattern="WebResource.axd" negate="true"/>
                        <action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent"/>

                    <!--End Fix 5 Common SEO problems using URLRewrite module and Web.config-->

Place at between:


Tuesday, April 24, 2012

RESOLVED: The solutions for addition s1600 to image at Picasa

Recently, Picasa has changed their privacy and default size for images when you upload using API to be 512px. Mean of smaller than the original size of every images. Big problem, if your websites have embedded these images.

Picasa support give a solution like addition "s1600/Filename.jpg" instead of old name in every image urls. But I can't modify every post when my blog/websites have had more than hundreds or thousands post. Too much, to modify by hand :(

My solutions as the following hope to resolve this if you have same problems.

Solution 1: (update data in column containing image url by update query, tested for SQL Server)

update [e_Image] set
imageurl= replace(imageurl,reverse(left(reverse(imageurl), charindex('/', reverse(imageurl)) -1)),
's1600/'+ reverse(left(reverse(imageurl), charindex('/', reverse(imageurl)) -1))) 

Execute, and see the results.

Solution 2:  (use javascript to replace old file name with new name contain "s1600/" when page load)

This solution is coded  by youself. 


Query to get FileName from URL (in SQL Server)

There are queries to get the file name from a column named: 'ImageUrl' containing list of image Url.

SELECT imageurl
  ,reverse(left(reverse(imageurl), charindex('/', reverse(imageurl)) -1)) as 'File Name'
 from [e_Image]

And result as the following: