Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

index.asp or /

         

stevelibby

1:07 pm on Jun 4, 2010 (gmt 0)

10+ Year Member



I have been doing some analysis on a site that has site links given to it buy google that point to /index.asp also all internal links are /index.asp.
What should i do? should i put a canconical tag in to change all / to /index.asp or should i slowly work on changing all to /
?

g1smd

6:48 pm on Jun 4, 2010 (gmt 0)

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



Change the links to point to the root "/" instead.

Later, redirect requests for example.com/index.php to example.com/ with trailing slash. Use a 301 redirect.

jdMorgan

7:54 pm on Jun 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Later, redirect requests for example.com/index.php to example.com/ with trailing slash. Use a 301 redirect.

There's a 'trick' to this. Be sure to redirect only *direct client requests* for the URL-path example.com/index.asp. Do not attempt to redirect internally-rewritten requests for the file-path /index.asp, or you will get an infinite rewrite/redirect loop.

This internal rewriting involved in this potential loop is typically done by the DirectoryIndex directive of mod_dir on Apache, or the equivalent function on IIS servers.

Take heart in the fact that it's actually harder to describe this requirement than to code it... :)

Jim

youfoundjake

8:11 pm on Jun 4, 2010 (gmt 0)

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



I was under the impression, that with IIS, a 301 could be done from non-www to www or vice versa, but with how IIS handles the rewrites, there will always be a default.asp or default.aspx or index.asp or whatever, and that there can never really be a /.

Oh, and maybe the mods can move this to the Microsoft IIS Web Server and ASP.NET forums.

dstiles

8:47 pm on Jun 4, 2010 (gmt 0)

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



I've found the best way for IIS is:

Set up the primary site record in IIS Console to direct www.example.com to the web site proper

Set up a second record in IIS console to 301 example.com to www.example.com (this can also carry the www and non-www for secondary domains - eg example.co.uk)

Tell google etc that www.example.com is your primary URL rather than example.com

Ensure ALL links to the home page within the site are to www.example.com/ (you do not usually have to specify www.example.com, only the / - eg href src="/")

Add a canonical redirect for /index.asp to use / (there will be /index.asp hits, from bookmarks, badly placed links in other sites, etc); it's a good idea to include canonicals to handle any legit or illegit querystrings that can change your primary URLs for home and other pages.

youfoundjake

12:41 am on Jun 5, 2010 (gmt 0)

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



Ok, bear with me.. Can a site running on IIS have a site root without any kind of index or default.asp? In other words, can the actual address in the browser be http://www.example.com/ or will it always have the .asp page at the end?

jdMorgan

2:22 am on Jun 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, based on the implications of dstiles' instructions in the post above, it sounds like the address in the browser address bar would/could be http://www.example.com/ as you desire.

If the server didn't implement this correctly, the result would be an infinite loop as URL http://www.example.com/ was internally rewritten to /index.asp and /index.asp was externally redirected back to http://www.example.com/ and the cycle repeated.

The same thing happens on Apache if this isn't implemented correctly.

Jim

youfoundjake

3:31 am on Jun 5, 2010 (gmt 0)

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



Ok, good to know. The reason I pressed was that I thought at some point I read/heard that IIS had to use default or index.asp since it didn't have the redirects like apache. If it did, it would be pointless to have a canonical to / if / always resolves to *.asp

jdMorgan

4:56 am on Jun 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure I understand your use of 'resolves' -- On a properly-configured server, the URL http://example.com/ resolves to the file /index.asp -- or index.php, or index.html, etc.

One thing that really helps with understanding external redirects and internal rewrites in Apache mod_rewrite and ISAPI Rewrite on IIS is to separate the concepts of URLs and server filepaths -- or equivalently, URL-space and server filesystem-space. They're two different things, 'associated' only by the action of a server. Keeping them as separate concepts clears up an awful lot of 'mysteries' about the current topic and many others.

For example, a URL 'exists' as soon as it appears as a link on a page on the Web. It doesn't matter if it resolves to an existing domain or server or to an existing file on that server -- It exists and will get spidered by search engines. On the other hand, a file exists on a server as soon as it is created in the server filesystem, regardless of whether any URL resolves to it.

The basic function of a Web server is to 'associate' URLs with filepaths, so that Web clients need not know any details of the server's internals -- its operating system, filesystem layout, naming conventions, etc. In fact this is the basic purpose of a server; The earliest ones did little more than that, in fact.

Keeping these facts in mind can conceptually simplify many projects, such as implementing search-engine-friendly URLs, etc.

I don't want to pull this thread any further off-track, so hopefully, dstiles will check in again soon and answer/confirm your question directly. :)

Jim

dstiles

9:39 pm on Jun 5, 2010 (gmt 0)

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



youfoundjake: You should always set up a default home page name in the IIS manager (under Documents tab).

MS defined this to be default.asp for some daft reason but anything is ok as long as it's defined. In the early days I set it to index.html (because I came from Linux to MS); nowadays it's set on most of my sites to index.asp because the newer sites are all written in ASP. You can use different names and extensions to suit the site (eg homepage.php).

The presence or absence of this definition defines the behaviour of the server if it gets a URL www.example.com/ (if the / isn't supplied initially by the browser: something - I think the browser itself - adds it). If there is no file specified by the browser and no default specified in the server then the server will return either a directory listing of the site (if the site is set up to do that - I don't recommend it!) or an error code (can't recall which one).

If the default file (eg index.asp) is specified in the server's Documents list AND it exists in the root directory then the page will be returned and the browser will (should) retain the URL www.example.com/ in the Location bar.

The Documents list can have any reasonable number of default files. The list will be checked top down until a match is found or it runs out of options. Sometimes useful during development.

The same behaviour happens for folders under the root - eg www.example.com/myfolder/ will return the default file (index.asp) from within the folder myfolder, if it exists. Etc.

I recommend having a dummy redirect default for folders which do not otherwise have any pages (eg image library). Eg /myfolder/index.asp would redirect (usually) to the home page or perhaps on more complex sites to an error trap of some kind. The latter might be better nowadays given all the hack attempts that try any combination they can get!

tedster

11:17 pm on Jun 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dstiles, thank you for a top quality post - we don't see as much information in here about IIS as we do about Apache and your input is most welcome.

If there is no file specified by the browser and no default specified in the server then the server will return either a directory listing of the site (if the site is set up to do that - I don't recommend it!) or an error code (can't recall which one).

By default in these situations, IIS returns an Error message of "Directory listing denied" with an HTTP status of 403 Forbidden. The server admin can change this behavior, but it's rarely a good idea.

dstiles

10:38 pm on Jun 7, 2010 (gmt 0)

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



So it does but I didn't trust my memory. Thanks for the praise. <blush>