homepage Welcome to WebmasterWorld Guest from 54.161.155.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
301 Redirect Questions - www vs non-www
Redirecting the right way with 301
bo0oost




msg:3334604
 6:24 am on May 9, 2007 (gmt 0)

Ok, been doing some house cleaning.

I'm trying to make sure all my url issues are non existent (read: supplemental hell).

So far I have:

http://example.com redirecting to http://www.example.com
http://example.com/test/ redirecting to http://www.example.com/test
http://example.com/test.asp?t=1 redirecting to http://www.example.com/test.asp?t=1

My problem is...

I can't redirect:

http://www.example.com/default.asp to http://www.example.com

FireFox says there is in infinite redirect, and it can't continue.

Anyone have any suggestions?

Thanks!

[edited by: encyclo at 3:04 pm (utc) on May 10, 2007]
[edit reason] switched to example.com [/edit]

 

keto




msg:3335905
 1:57 pm on May 10, 2007 (gmt 0)

Are you doing this within IIS or using a script to evaluate and rewrite the URL?

I am working on the same thing as you but I also want to include a way to handle typo domains.

defanjos




msg:3335982
 3:15 pm on May 10, 2007 (gmt 0)

Anyone have any suggestions?

Look into isapi_rewrite

asusplay




msg:3344787
 6:21 pm on May 20, 2007 (gmt 0)

Yes, it's impossible to redirect http://www.example.com/default.asp to http://www.example.com as you said. Basically I enquired about this on here about a year ago when the duplicate penalties were occuring with Google because of the www and non www issue.

There's only 3 options in my view:
IIS, which is not possible on shared hosting
ISAPI, which again is not an option if you're on shared hosting
or if you are having problems because search engines have indexed www.example.com and www.example.com/default.asp as identical then you should re-save the default.asp file as index.asp (as an example) and do a 301 redirect to the root.

Then go through your site thoroughly and make sure there are no direct links to default.asp and instead things link to the root.
It is possible however (and worthwhile) to 301 redirect http://example.com/default.asp to http://www.example.com

Hope this helps

defanjos




msg:3345296
 12:12 pm on May 21, 2007 (gmt 0)

ISAPI, which again is not an option if you're on shared hosting

Some hosting companies will install isapi_rewrite, or similar, if you pay for the license.
You may have to look around a bit, but there are many that do it.

jaytee




msg:3350105
 8:12 pm on May 25, 2007 (gmt 0)

Rather than using third party tools, you can do a lot in the Application_BeginRequest event in Global.asax.vb. You can intercept specific pages using:-

LCase(Request.ServerVariables("SCRIPT_NAME")).ToString...

and do some pretty sophisticated things using...

HttpContext.Current.Response....

and

Context.RewritePath

It is pretty much what Isapi filters do but within .NET itself.

Panic_Man




msg:3350832
 9:21 pm on May 26, 2007 (gmt 0)

Assuming you're running a windows server, you'll notice that the default documents are configured with captial letters:

Index.html
Default.asp etc.

You can 301 redirect http://www.example.com/default.asp to http://www.example.com/ just by checking for the capital (if 'default.asp' then redirect, if 'Default.asp' then dont.)

Of course, it's not 100% perfect, because http://www.example.com/Default.asp exists as a duplicate but you're not likely to be linking internally using a capital letter anywhere in your website and most likely neither is anyone else.

[edited by: Panic_Man at 9:23 pm (utc) on May 26, 2007]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved