PDA

View Full Version : Standardizing URL on ASP.NET Site



TechEvangelist
02-17-2006, 11:45 AM
I'm providing SEO advice to a new client who has a corporate Web site built using ASP.NET. I am a classic ASP and PHP developer, but have not worked with ASP.NET. One of the problems I found is that the search engines have indexed the site under two versions of the URL, one with and without the www subdomain. That's a common problem. The secondary issue is that the home page can be reached using 4 variations of the URL, as in:

http://www.domainname.com/
http://domainname.com/
http://www.domainname.com/app/ (home page actually resides here)
http://domainname.com/app/

Is there an ASP.NET developer that knows the best way to deal with this issue on this platform? I know I need a 301 redirect routine to standardize the URLs to http://www.domainname.com/.

This is a common problem that is easily resolved on Unix and Linux servers using .htaccess, but I have not found a similar solution for ASP.NET sites. ASP.NET does have a built-in URL rewriting routine (it's about time) that looks like it uses an XML file for the rewrite, but I have not found a reference to a site-wide 301 redirect or a method to force standardization of the URLs. I'm looking for a recommendation for the best way to deal with this issue with ASP.NET.

rumblepup
02-17-2006, 12:52 PM
Not a coder, but I think I can help.

In the asp.net web.config file, which is a global file to your application that will set a predefined set of settings, you can actually state a set of rules for IIS to follow on how to handle the url. It's part of the asp.net engine. You can change mysite.com/app.aspx?topic=13 to mysite.com/bluegrass/13/default.aspx and so forth. However, I don't think that dynamic content is a problem for SE's anymore. I know your problem has a resolution, but since I'm not a coder, I can't exactly point it out.

HOWEVER, I can point you to some references.

asp.net (http://asp.net) - this is the online community website for asp.net
aspnet.4guysfromrolla.com/1.x/ (http://aspnet.4guysfromrolla.com/1.x/) - articles and resources
www.dotnetjunkies.com/ (http://www.dotnetjunkies.com/)- another resource.

Hope this helps a little.

cyanide
02-17-2006, 01:11 PM
I'm not an asp.net guy :)

However, I have seen the following code you could try

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.somedomain.com");
}
</script>
-

TechEvangelist
02-17-2006, 05:49 PM
Thanks for the help with this thus far.

Cyanide, I did find the script that you posted, but that looks like a page level script. I'm really looking for a site-wide solution similar to mod_rewrite in Apache's .htaccess file. All three of the secondary versions of the URL need to be converted to the primary URL using a 301.

I know our world is dominated by PHP and classic ASP, but there has to be an ASP.NET developer out there who knows how to do this.

cyanide
02-17-2006, 06:55 PM
ahh, I see...

Well for the home page being in the app folder...
- any chance it can be moved into the root directory?
That would solve half your problem.
I see linux/apache sites doing this all the time, and I always encourage them to move it.

Keimos
02-17-2006, 09:37 PM
Hi TechEvangelist,

Its not a coding thing, as Cyanide has pointed out, why are you complicating things.

http://www.domainname.com/
http://domainname.com/

are the same domain or address as are

http://www.domainname.com/app/ (home page actually resides here)
http://domainname.com/app/

Are these all repeats of the same page? Have to ask!!

home page should reside in the root folder.

Basically you are overcomplicating things. KISS

Keimos

TechEvangelist
02-18-2006, 08:56 AM
I understand the comments and appreciate the help. I didn't design the site. For some reason, problems with unusual site architectures are common with ASP.NET sites. I can't explain why this is, but I have seen ASP.NET site stuctures that are much more bizzarre and illogical than this.

I completely agree that the home page should be in the root directory, and I do plan to make that recommnedation. I can't explain why some developers place it elsewhere. It doesn't make sense to me either.

My question is related to the best method to use to set up the 301 redirects. I can't find any information as to how to do this properly with ASP.NET. I will recommend a page level 301 redirect for the copy of the home page in the subdirectory.

The problem I still have to resolve is related to using a 301 redirect to eliminate the versions of the URLs without the www subdomnain in the search engines. I thought that this should be done with ASP.NET's internal URL rewrite program. If I cannot find a solution along these lines, I plan to recommned the old workaround that requires two sites to be set up on the server. One is the main site using http://www.domainname.com. The other site is set up using http://domainname.com and is set up in IIS as a permanent redirect to http://www.domainname.com. No Web pages actually exist on the second site because IIS redirects all the traffic.

Does anyone know of a solution using ASP.NET's internal URL rewrite program?

cyanide
02-18-2006, 01:35 PM
Does the client have control over the server?
Or maybe the host can be queried?

In IIS

Go into Internet Services Manager, right click on the file or folder you wish to redirect. Select the radio titled "a redirection to a URL". Enter the redirection page, check "The exact url entered above" and the "A permanent redirection for this resource", then click "Apply".

Grasping at straws :)

incrediblehelp
02-19-2006, 10:41 AM
TechEvangelist have you looked into ISAPI rewrite (http://www.isapirewrite.com/)?

TheGarty
02-19-2006, 09:19 PM
I dont see why this really matters???

All you have to do is make sure that all the links to the site from external sources, and internally in the website, are to the same link.

Then it really doesnt matter, does it?

Also, depending on the way the site works, you could replace the files in whatever the directories are and do 301 redirects to the page you want?

My advice is to ignore the pages you dont want, and concentrate on the ones that you do.