Showing posts with label SEO. Show all posts
Showing posts with label SEO. Show all posts

Monday, January 6, 2014

, ,

URL Rewrite Using .htaccess File (Removing Page Extensions)

Introduction

In one of my previous article I have explained how to rewrite your website URL in C#(.NET). Here I will show you a simple example of achieving this using the .htaccess file.

Behind The Scene

Very often you need to rewrite your website URL to make it search engine friendly. You may need to remove file extension from the pages.


Lets say you have a page named "services.aspx", If you look into the page then you might not get a proper idea what type of content your page is representing. Exactly the same way Search Engines also look in the pages and page names. So its very important to give a specific and user and/or SEO friendly URL names.

If we consider the above page then lets make it a bit user friendly by changing what it is representing actually. Lets change it to "seo-services-in-india.aspx", now you can see this name actually means something to users and/or Search Engines.

Another thing its a better to have pages with no extension, but you know its impossible to miss the file extension of a page (ie. .php, .html, .jsp, .aspx). So what you need you need to force the browser to render the "seo-services-in-india.aspx"  under the name of "seo-services-in-india".

In my previous article on URL Rewriting, we have achieved the same goal by giving the dummy page name according to our choice that does not depend on the real page name.

e.g we have rewritten a URL from "contact.aspx"  to "my-contect-details", where the page name actually changed from one to other programatically. But here we will not change it but we will remove the extension only.
 <IfModule mod_rewrite.c>
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^([^\.]+)$ $1.html [NC,L]
     RewriteRule ^([^\.]+)$ $1.aspx [NC,L]
     RewriteRule ^([^\.]+)$ $1.php [NC,L]
     RewriteRule ^([^\.]+)$ $1.jsp [NC,L]
 </IfModule>

Now put the above code into your .htaccess file, and this will remove all the .html extensions from all your pages automatically. and the pages can be rendered without a file extension of  ".html", ".aspx", ".php", ".jsp"


Happy Coding...


Publisher: Tapan kumar - 6:11 AM

Friday, October 18, 2013

,

Enforce Browser To Add WWW Before Your Website




Introduction




Its very important in the eyes of Search Engine Optimization to render your website with a www in the beginning. If your site is being rendered with a www and also without a www then there is a big problem.



To overcome this issue lets find out a solution.






Behind The Scene






lets consider your website's name is "www.tapankumar.in" , So when you type www.tapankumar.in in the browser then it will open the site. Again if you type tapankumar.in in the browser then also it will open the site.



Now the problem is that when a search engine like Google try to crawl your site it will find TWO - 200 response against "www.tapankumar.in" and "tapankumar.in" ,  Hence the search engine consider this as a duplicate url.



You need to resolve this issue in order to get better SEO results, and here is a way to do this using your .htaccess file.


 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.tapankumar\.in$ [NC]
RewriteRule ^(.*)$ http://www.tapankumar.in/$1 [R=301,L]
</IfModule>

Now put the above code into your .htaccess file, and this will prepend a "www" before your website address automatically. 




Happy Coding...


Publisher: Tapan kumar - 3:58 AM