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

September 06, 2010

Implementing 301 Redirects for ASP Sites at the Application Level.

 

The easiest way is doing it in IIS Level. But if you have shared hosting, where you do not have control on the Web Server and your hosting provider didn’t agree to do it, you have no option other than doing it at the application level.

So you need to include the following code in all of your ASP pages

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "www.freemanortho/new-page.asp"
%>

Whereas this will not work in FireFox and the following error message is thrown.

“The page isn't redirecting properly .firefox has detected that the server is redirecting the request for this address in a way that will never complete. '”

What if you have 1000+ pages and it is difficult to change and hardcode in all the pages , that is time consuming and maintenance headache. What if a new page is created, then again you need to write this code too.

We need to write a best practice more generic approach that gives optimized output, better results with a minimum overhead

Instead of hard coding domain names and page names

Get Domain Name

Get Domain name using request.ServerVariables("HTTP_HOST"))

Get Path Name

The path of the pages can be dynamically get by = request.ServerVariables("PATH_INFO")

Get QueryString

If there is querystring append the querystring to the URL along with path name.

request.ServerVariables("QUERY_STRING")

We can even now  handle the querystrings if any in the live websites by appending pathname and querystring to the url.

Use the below code to redirect the pages dynamically.

<%

Domain_Name = lcase(request.ServerVariables("HTTP_HOST"))

if domain_name <> "www.freemanortho.com" Then

HTTP_PATH = request.ServerVariables("PATH_INFO")

QUERY_STRING = request.ServerVariables("QUERY_STRING")

theURL = "http://www.freemanortho.com" & HTTP_PATH

if len(QUERY_STRING) > 0 Then

theURL = theURL & "?" & QUERY_STRING

end if

Response.Clear

Response.Status = "301 Moved Permanently"

Response.AddHeader "Location", theURL

Response.Flush

Response.End

end if

%>

Create a file called Redirect.asp and

Now include this file in the include file in the header.asp .
<!-- #Include file="redirect.asp" -->

As the header.asp is the include file that is called in all the pages, the code gets called in all the pages.

Now our site, gets redirected to www.freemanortho.com instead of http://freemanortho.com throughout the site in any page

January 24, 2010

Community TechDays at Hyderabad

Follow me on my twitter ID

I would say that CTD at Hyderabad is success as we can see huge crowd more than 250 for the sessions. Though most of them are dev crowd every one stayed till the end of the event. What the passion the techies have on the technology!!

Harish Ranganathan was organizer for the event, came and helped in clearing the security check and having spot registrations.

Event started with my session on VS2010 Web Development Enhancements. The response was pretty good and with lots of very good questions during the session, after the session and also during the lunch. I was very happy that I would able to make it though I was busy at the MVP open day for the past three days .Yes. It was a very busy week for me. I explained the features on VS2010 spoke on ASPNET4 features and covered ASPNET4 demos and chart control. You might have noticed the excellent features on VS2010.

Arun's session was cool! WCF,WCF,WCF …everyone knows basics but don't really know how to use it in real time. We might struck in developing day to day apps incorporates, its worth for every one for attending the session.

Hariveer Singh, Program Manager at Microsoft gave cool demos on VS2010 LAB Management, which is going to be released soon. This is the instant feedback from audience for the product - Excellent and worth product.

Most of the people are from DEV crowd, I could see their interest in attending IT PRO sessions too.

Community-Techdays-Audience
Muqeet spoke on IIS 7.5 and SEO Tool KIT, where he got questions from DEV audience. The quality of the questions we got from Hyderabad UG is a lot improved and I really like the way they are interested and enthusiastic in learning advanced technology and technology changes.

Though we have continuous sessions without breaks, being last session, DEV audience Vijay made audience to sit and listen to his session through his interactive presentation.

Finally I can say that made the event success and that made professionals to reach what they are expecting.

Some of you have asked me what is an MVP? How to become? And all .. I already blogged about it 2 years ago. Those who are interested in MVP details can find here
What is an MVP?

Thanks to Harish Ranganathan for successfully co coordinating and helping in making event success.

Here is link for MUGH group to spread the word

Please find my presentation uploaded here