Alternate names for index.html


#1

I would like to have my default homepage point to something like index_christmas.html, index_newyear2002.html, etc.
Is such a thing possible?
Thanks, and happy holidays


#2

Yes it is. If you must! :slight_smile:

Create a new plain text file using Notepad or equivalent.

Write the following line into the file:

DirectoryIndex index_christmas.html Save the file named [color=#CC0000].htaccess[/color]

(Note that the leading period is intentional.)

Upload the file to the directory where you wish this directive to take place. Upload in ASCII transfer as this is only a plain text file after all.

And pronto. The web server should look for the file specifided in the .htaccess file as the default index for that directory.

Hope this helps.

Wil


#3

well the easiest thing is probably to rename your index page, but you should be able to create a text file named ‘.htaccess’ with the line:
DirectoryIndex index.html index.htm My_kewl_index_page.htm

where ‘My_kewl_index_page.htm’ is the name of your index page.

i’d personally suggest just renaming your page though :> generally, the browser bar will just say:
http://veggiechinese.net/
instead of:
http://veggiechinese.net/My_kewl_index_page.htm

you can also use an .htaccess file to redirect to the URL you want; this requires the use of tags, so you’d create a refresh tag in your index.html page that redirects to the page you want. this will change the browser URL.


#4

I’m just curious why you would bother doing this. If you are thinking of saving old home pages, you could simply RENAME them while keeping the current as index.html. In this way, you’ll save a lot of time and work.

Alternatively, you may also REDIRECT index.html to whatever.html; visitors to yourdomain.com/ would automatically be forwarded; since you have access to your root (where you place your .htaccess file), it’s much better than the meta tags REFRESH command (which is slower).


#5

Actually, you can list several different names in the DirectoryIndex directive.

If you list

DirectoryIndex index.html index.htm /noindex.html

then the server will display the first file it comes across in the list. If you have software that names your files with .htm instead of .html, this would make the server display index.html if there was one, and if not, look for an index.htm, and then look for a noindex.html file in your root directory, before giving up and listing all the files in the directory.

The advantage of having a /noindex.html file is that if someone snoops in a directory where you forgot to put an index.html file, you can display a page that says “Private. No girlz aloud” like the little boys’ treehouse.

Not letting people know any more than necessary about your file structure is called “security by obscurity” and it’s not the most effective security tool, but it can help a little, and at the cost of virtually no effort.


#6

Thanks for your help – you were absolutely right! It is a lot easier to rename individual “homepages” according to the season etc: I was looking for an easier way out – but it’s good that I’ve cleaned out my folders.


#7

[quote]Actually, you can list several different names in the DirectoryIndex directive.

[/quote]

Yep - i should have made this clearer in my example (although i did specify several).

[quote]The advantage of having a /noindex.html file is that if someone snoops
in a directory where you forgot to put an index.html file, you can display
a page that says “Private. No girlz aloud” like the little boys’ treehouse.

[/quote]

You can also just put:
Options -indexes
in an .htaccess file to disable index browsing in a particular directory tree. This will just go to a regular generic 403 error page though.

You can re-enable it for a particular directory tree with:
Options +indexes.

I didn’t know about the /noindex.html thing though - that’s pretty cool.

Note that using the DirectoryIndex tag at all will override our defaults (which have index.phtml, index.cgi, etc. listed) so you might run into problems if you don’t specify a full list.


#8

I hope I haven’t confused anyone with /noindex.html

There isn’t anything special about the “noindex” name. You can call it anything you want to. And you do have to create a page if you want your own message to display.

What I was trying to point out is that you can specify a file in a different directory. And it doesn’t have to be a static web page. You could use

DirectoryIndex index.html /cgi-bin/ginrummy.cgi

if you want…


#9

A better way of doing this would be to redirect Error requests to purposed made documents, though. I think the Dreamhost servers are already set up for all 404 and 500 errors to go to /error.html ???

Just use the Options NoIndex directive to override the default.


#10

Hey, thebeck…

I kinda approach it from the opposite direction; I rename the non-current indexes with their own monniker so I know who everyone is. Like:

spring_index.html
summer_index.html
fall_index.html
index.html <-- This one’s the current “winter” index

In the spring, I’d rename index.html to winter_index.html and change spring_index.html to index.html.

That way, there’s no need to mess around with .htaccess and such.

Have fun!

…Bob W.