How to set a website home page

Discuss all aspects of programming here.

Moderator: The Mod Squad

User avatar
Thrustwyn
Brown Belt
Brown Belt
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

How to set a website home page

Post by Thrustwyn »

Hi all -

This is probably a silly question, but how does one set a particular file or page to run when a particular website is accessed -

e.g. www.example.com

My problem - I have uploaded my site to the host server, but when one navigates to that address, they get the index list of all files, etc. on the site.

Instead, what I want is for them to get the homepage I intend. Of course, if one knew the page, they could simply add it into the address line...

e.g. www.example.com/homepage.htm

What is the way to default to have the person default to the home page by only typing in the website (minus the actual homepage file)?

(I hope this question is clear, and not confusing).

All answers appreciated - thanks!

T.
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
Posts: 14303
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine
Contact:

Post by Toby B. »

It is done via you Apache httpd.conf file or .htaccess files..... All depends on your hosting package. Who do you have as a webhost?
User avatar
Thrustwyn
Brown Belt
Brown Belt
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Post by Thrustwyn »

Ah, I was sort of on the right track - I had started to fiddle with the .htaccess file, but the tutorial/help provided by the webhost did not really cover that very well. I use Bluehost, by the way.

Can you (or anyone) provide a simple example showing code that would load a particular page upon navigation to a site?

I fiddled with redirect, trying to redirect to a file, but I am thinking that command only allows one to redirect to directories/folders, not specific files.
~Rob
Black Belt 4th Degree
Black Belt 4th Degree
Posts: 4941
Joined: Sun Dec 28, 2003 8:26 pm
Location: Norwich, UK
Contact:

Post by ~Rob »

I just uploaded index.htm to my publichtml file and bam, it worked, but my host is for beginners
[img]http://i3.photobucket.com/albums/y83/RobPope/sigmove.gif[/img]
[b]Jocuri cu impuscaturi[/b] si alte genuri, pentru toate varstele doar pe [url=http://smarturl.it/jocuri]acest link[/url] - distractie si amuzament garantat!
User avatar
Thrustwyn
Brown Belt
Brown Belt
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Post by Thrustwyn »

Thanks for the reply. I too tried that, as the help indicated that there should be an index.htm file present. However, that didn't do anything - it still just listed all the files and directories...

Based on the previous response, I am guessing that if this .htaccess file is present, it probably needs to have something in it to direct to the home page file (??).

(While on the topic of the index.htm file, however, is that always required? Previously, I used free website hosting from my usual ISP, and just linked to a particular file (not index.htm) when linking to my home page.)

Still hoping someone can give an example of what the .htaccess file should contain in order to set a particular file as the default page.
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
Posts: 14303
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine
Contact:

Post by Toby B. »

Will post something later tonight after work.
User avatar
Thrustwyn
Brown Belt
Brown Belt
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Post by Thrustwyn »

Ah, much appreciated, Toby!

T.
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
Posts: 14303
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine
Contact:

Post by Toby B. »

Create a text file and name it .htaccess. Insert this text into the .htaccess file!

Code: Select all

DirectoryIndex index.htm index.html index.html.var
This should allow the use of .htm extensions, to prevent seeing a file tree when trying to access the page/directory...

I hope this helps..
User avatar
Thrustwyn
Brown Belt
Brown Belt
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Post by Thrustwyn »

Hi Toby -

Awesome, got it to work (after noobishly entering everything you listed under code, all 3 versions of the index reference :P).

I take it, however, that I must use a file named "Index.***" - it's not possible to refer to a file without that naming scheme?

Anyway, I'll rework the links - thanks again for the help - greatly appreciated! :)

Thrustwyn
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
Posts: 14303
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine
Contact:

Post by Toby B. »

it's not possible to refer to a file without that naming scheme?
Its probably possible, but not sure if it would work....
Post Reply