Welcome to WebmasterWorld Guest from 54.145.209.34

Forum Moderators: ocean10000

IIS 5.0 and 301 redirection

how to redirect mysite.com to www.mysite.com?

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

5+ Year Member



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]

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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.

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

10+ Year Member



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.
2:52 pm on Oct 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

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

5+ Year Member



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.

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

5+ Year Member



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)

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

5+ Year Member



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,

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

5+ Year Member



you'll find your answer here:
[askdavetaylor.com...]
12:39 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

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

10+ Year Member



Use URL rewrite.
1:02 pm on Oct 13, 2005 (gmt 0)

5+ Year Member



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]

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

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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]

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

5+ Year Member



Thanx,

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

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

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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]

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

5+ Year Member



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.
1:38 pm on Oct 13, 2005 (gmt 0)

5+ Year Member



Sorry pageoneresults,

And thanx for this link.

Vineet

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

WebmasterWorld Senior Member pageoneresults is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month