How to set a website home page

Discuss all aspects of programming here.

Moderator: The Mod Squad

How to set a website home page

Postby Thrustwyn » Tue Dec 20, 2005 10:57 pm

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.
Thrustwyn
Brown Belt
Brown Belt
 
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Postby Toby B. » Tue Dec 20, 2005 11:43 pm

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?
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Thrustwyn » Wed Dec 21, 2005 9:22 am

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.
Thrustwyn
Brown Belt
Brown Belt
 
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Postby ~Rob » Wed Dec 21, 2005 9:57 am

I just uploaded index.htm to my publichtml file and bam, it worked, but my host is for beginners
Image
Jocuri cu impuscaturi si alte genuri, pentru toate varstele doar pe acest link - distractie si amuzament garantat!
~Rob
Black Belt 4th Degree
Black Belt 4th Degree
 
Posts: 4941
Joined: Sun Dec 28, 2003 8:26 pm
Location: Norwich, UK

Postby Thrustwyn » Wed Dec 21, 2005 11:39 am

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.
Thrustwyn
Brown Belt
Brown Belt
 
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Postby Toby B. » Wed Dec 21, 2005 2:08 pm

Will post something later tonight after work.
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Thrustwyn » Wed Dec 21, 2005 7:27 pm

Ah, much appreciated, Toby!

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

Postby Toby B. » Wed Dec 21, 2005 9:29 pm

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..
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Thrustwyn » Wed Dec 21, 2005 9:48 pm

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
Thrustwyn
Brown Belt
Brown Belt
 
Posts: 281
Joined: Sun Mar 02, 2003 1:44 am
Location: Vancouver, BC, Canada

Postby Toby B. » Wed Dec 21, 2005 11:17 pm

it's not possible to refer to a file without that naming scheme?
Its probably possible, but not sure if it would work....
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Next

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest