Forum Moderators: open

Message Too Old, No Replies

directory url canonicalization with IIS6

         

phranque

3:52 am on Mar 13, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



this is my first chance to mess around with IIS Manager.
i am trying to figure out how to redirect http://www.example.com/index.html to http://www.example.com/ with IIS6 (no ISAPI_Rewrite) and i can't get it working properly.
i have the default content page set to index.html for the site.
when i redirect that index.html to http://www.example.com/ it causes a recursive redirect problem ("Redirect loop detected").

darrenG

3:05 pm on Mar 13, 2009 (gmt 0)

10+ Year Member



Hi,

You are telling IIS to redirect every request for index.html to / right?

The trouble is / is a request to index.html as far as IIS is concerned. So you are essentially redirecting index.html to... index.html.

Can't do it, without rewriting as far as I am aware..

phranque

1:13 am on Mar 14, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i had always suspected iis was fundamentally flawed but now that i have looked under the covers i am certain of it.

can someone tell me if they have fixed this in IIS7 or does this require an add-on (ISAPI_Rewrite)?

darrenG

10:55 pm on Mar 15, 2009 (gmt 0)

10+ Year Member



It is the correct behaviour, nothing to fix IMO.

Yes, you will require ISAPI_rw

phranque

6:24 am on Mar 16, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



non-canonical urls are not "correct behavior".
you don't want to serve duplicate content for "/" AND "/index.html" which is the exact behavior i am trying to "fix".

in addition, "index.html" per se is meaningless in the url (there is no keyword there), exposes your technology, and makes the url less flexible for future technology changes.
the general purpose of the index.html document is to be the "default" document for displaying the contents of a directory.
to me "default" means you don't have to specify it.

on the other hand, apache makes it possible to fix this:
how to remove index.html from the URL [webmasterworld.com]

phranque

11:26 pm on Mar 16, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



more on the subject from a previous thread:
Linking to Root: / vs. /index.htm [webmasterworld.com]

mattur

1:45 pm on Mar 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's some more discussion with ISAPI_rewrite 2/3 solutions in this thread: /directory/ and /directory/index.html are duplicate content? [webmasterworld.com]

IIS7 has a URL Rewrite Module [learn.iis.net], or you can parse all requests in IIS6 (wildcard handler mapping) or in IIS7 (integrated pipeline mode) as ASP.NET requests, and use its built-in URL rewriting facilities and/or the UrlRewritingNet.UrlRewrite [urlrewriting.net] module.

i had always suspected iis was fundamentally flawed but now that i have looked under the covers i am certain of it.

I've done a lot of IIS in the past and I agree ;) IIS7 is the first half-decent version of IIS imho.

phranque

12:41 am on Mar 30, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i haven't found a url for downloading the IIS6 URL Rewrite Module.

Ocean10000

2:26 am on Mar 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



They do not offer a URL Rewriting Module for IIS 6. It is only for IIS 7 at the moment. IIS 7 was redesigned to treat Asp.net Modules the same as ISAPI modules. URL Rewrite is a Asp.net Module but will only really work in IIS 7. If it does anything in IIS 6, it would need to be modified, and IIS 6 would have to be configured to map everything to the asp.net ISAPI component.

cybotron

8:35 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



Hi Guys,

I have already redirected non-www to www in IIS6 successfully.

I also want to redirect www.mysite.com/index.html to www.mysite.com.

Any ideas?

Thanks

Cy

darrenG

11:26 am on Mar 31, 2009 (gmt 0)

10+ Year Member



When I said correct behavior, I wasn't refering to 'non-canonical urls are not "correct behavior".', I was referring to the behavior IIS was exhibiting when you erroneously set a redirect from index.html to / - which as far as IIS is concerned, are the same physical files.

g1smd

9:05 am on Jun 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The whole idea of a server is that external URLs, and filesystem internal folder and page names, are merely 'associated' and that you should be able to alter their relationship at will.

So although the URL "/" is serviced by the file "/index.html", you should be able to independently change things so that the URL "/index.html" is not serviced by a file but instead returns a redirect to a different URL, such as "/".

Apache does allow that. Simply,

RewriteRule..[1]<snip>[/1]..[R=301,L]
enables the redirect to a different URL when the URL "/index.html" is requested, and
DirectoryIndex
associates the URL request "/" with the right file, such as '/index.html', on the server.

marcel

11:34 am on Jun 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With IIS7 rewrite module you can add the following to your web.config file:


<rule name="Default Document" stopProcessing="true">
<match url="(.*)default.aspx"/>
<action type="Redirect" url="{R:1}" redirectType="Permanent"/>
</rule>

phranque

12:44 pm on Jun 10, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Apache does allow that.

With IIS7 rewrite module...

the title of this thread makes discussion of apache and IIS7 solutions pretty much off topic...

marcel

12:49 pm on Jun 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...can someone tell me if they have fixed this in IIS7...

You asked the question yourself...