homepage Welcome to WebmasterWorld Guest from 54.227.77.237
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

    
IIS 5.0 and 301 redirection
how to redirect mysite.com to www.mysite.com?
effisk




msg:956767
 1:25 pm on Oct 7, 2005 (gmt 0)

Hi everyone,

I have a website on a IIS 5.0 server. Currently, my website in accessible via both http ://www.mysite.com and http ://mysite.com. Good.

But the thing is when I hit http ://example.com the url remains the same in the address bar and I want it to be redirected to http ://www.example.com via a 301 permanent redirection (as for [google.com)...]

How can I do that? I have access to all the settings so I can do whatever I want on the server (although I don't know much about IIS, I'm more familiar with Apache...)

thanks to those who can answer me.

cheers

effisk

[edited by: Xoc at 12:32 am (utc) on Oct. 27, 2005]

 

BennyBlanco




msg:956768
 2:15 pm on Oct 7, 2005 (gmt 0)

I have been trying to get the same answer now for over a week. If you do happen to get the answer, can you please sticky mail it to me.

Thanks

john_k




msg:956769
 2:27 pm on Oct 7, 2005 (gmt 0)

The easiest way, with no coding involved, would be to create a second website for "mysite.com". Then use the IIS MMC to redirect all requests to "www.mysite.com."

If you can't do that, and if your pages are all ASP or ASPX, then you could put the redirect logic into a separate file and include that at the top of all of your ASP/ASPX files.

Barring either of those, you may be able to find an ISAPI component that will do this for you.

BennyBlanco




msg:956770
 2:39 pm on Oct 7, 2005 (gmt 0)

There must be an easier way to do it server side. Doing it on Apache is simple, can .Net really be so much harder. Well, of course it can, it is a Microsoft product.

john_k




msg:956771
 2:52 pm on Oct 7, 2005 (gmt 0)

The original question was for IIS 5.0. They didn't specify ASP or .Net. .Net is not a default part of IIS 5.0 (it needs to be added).

In IIS 5.0 and 6.0, ISAPI is the vehicle for preprocessing hits on a global scale. If you don't use ISAPI, then you need to do it with code in the requested file. That can be via an include. However, without ISAPI, the requested file still needs to be something other than a static .htm/.html file.

effisk




msg:956772
 2:53 pm on Oct 7, 2005 (gmt 0)

quote : " There must be an easier way to do it server side. Doing it on Apache is simple, can .Net really be so much harder."

I 100% agree. There must be an easier way.
It is so simple on an Apache server, I can't believe this is so complicated on IIS.

effisk




msg:956773
 2:56 pm on Oct 7, 2005 (gmt 0)

We have only .aspx pages.

The problem with the first solution proposed by john_k is that all anchors (for instance page.aspx?lr=test#74) are lost using this method (redirected to page.aspx?lr=test)

compose




msg:956774
 8:06 am on Oct 8, 2005 (gmt 0)

Hi effisk,

Sorry i have no answer for ur question but i think u know answer of my problem :)..

I am also facing same problem but i have linux hosting with apache server. When i open my site using "http://www.compose.co.in" it's not opening but when i use "http://compose.co.in" it's oppening site. can u tell why this problem is occuring and what is the solution of it.

Thanx.

Vineet,

effisk




msg:956775
 8:41 am on Oct 10, 2005 (gmt 0)

you'll find your answer here:
[askdavetaylor.com...]

john_k




msg:956776
 12:39 pm on Oct 10, 2005 (gmt 0)

We have only .aspx pages.

Since everything is in aspx pages, and using the IIS global method is not working, then the next alternatives are:
- Add the redirect logic via an INCLUDE file in the .aspx pages, or
- Add the redirect logic via inheritence in the .aspx.vb files, or
- Put the redirect logic into a globally available function and then call it from the Page_Load function in the .aspx.vb files.

Option 2 means you create your own base page class. This class inherits from "System.Web.UI.Page". Then change all of your other .aspx.vb files to inherit from your base class. Visual Studio hates this though, and you will always get an erroneous "Type Abstract" error when you open the associated .aspx files.

There may be a way of doing it with the web.config file, but I am not aware of it. If anyone knows the answer to this, please chime in.

Jalinder




msg:956777
 12:44 pm on Oct 10, 2005 (gmt 0)

Use URL rewrite.

compose




msg:956778
 1:02 pm on Oct 13, 2005 (gmt 0)

Hello,
i am facing a problem.as i told previous my site is opening using "example.co.in" and not with "www.example.co.in". then as per ur suggestion i write this in my .htaccess file

"Redirect permanent / http://www.example.co.in/"

But after uploading it when i use example.co.in it is taking more then 2 minute time. and after 2 minutes it open "www.example.co.in".

before this altyeration opening time was 15 seconds.

Can any body tell me what is wrong with it. am i using wrong code?

[edited by: tedster at 6:20 am (utc) on Jan. 15, 2007]
[edit reason] use example.co.in [/edit]

pageoneresults




msg:956779
 1:19 pm on Oct 13, 2005 (gmt 0)

These instructions from your Forum Moderator, Xoc, should do the trick if you don't have ISAPI_Rewrite installed.

IIS: Redirect a domain such as example.com to www.example.com [xoc.net]

compose




msg:956780
 1:21 pm on Oct 13, 2005 (gmt 0)

Thanx,

But i am not on Windows server i am on linux server using Apache.

pageoneresults




msg:956781
 1:31 pm on Oct 13, 2005 (gmt 0)

But i am not on Windows server i am on linux server using Apache.

My reply was for the topic starter effisk.

For mod_rewrite, this should provide the answers you are looking for...

An Introduction to Redirecting URLs on an Apache Server [webmasterworld.com]

effisk




msg:956782
 1:34 pm on Oct 13, 2005 (gmt 0)

These instructions from your Forum Moderator, Xoc, should do the trick if you don't have ISAPI_Rewrite installed.

IIS: Redirect a domain such as example.com to www.example.com

this does not work properly as I explained before. I lose the #anchors with this redirection.
compose




msg:956783
 1:38 pm on Oct 13, 2005 (gmt 0)

Sorry pageoneresults,

And thanx for this link.

Vineet

pageoneresults




msg:956784
 1:52 pm on Oct 13, 2005 (gmt 0)

This does not work properly as I explained before. I lose the #anchors with this redirection.

You are going to need a program like ISAPI_Rewrite to further refine your URI Rewriting capabilities.

P.S. I believe .NET offers some additional rewriting features. I've not used them since we have ISAPI_Rewrite installed and I can drop a rewrite rule in the .ini file within seconds.

RewriteRule /sub/file1.asp#anchor http://www.example.edu/sub/file2.asp#anchor [I,O,RP,L]

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