General Question

serenityNOW's avatar

Techie questions for web-developers/designers (details inside)

Asked by serenityNOW (3643points) May 25th, 2013

Okay, I’ll try to type this in a reasonably coherent manner :)

Say I have a website and an issue with where pages “land:”
If I have xx.domain: I know that if I place a file called “index.html” in any given folder, the browser will default to that page, so if I have xx.domain/index.html, if will automatically load that page – that’s good. But suppose I want to have the main page named something else – say xx.domain/index-main.html. How can I default to that page? If it doesn’t, then I get a generic list of all the files in that given directory: that’s bad.

Do I need some special code? I’m just a plain HTML & CSS guy, so I don’t know if there’s some special scripting? Do I work with my hosting company? It would also be ideal if I can prevent someone from going into my “images” directory? Is that something I can do with this magic coding, too?

Thanks and I can explain in more detail if need be!

Observing members: 0 Composing members: 0

8 Answers

ETpro's avatar

If your hosting service allows you to manage the .htaccess file, you can set the default page or pages in it. See http://davidwalsh.name/directory-index-homepage-htaccess

serenityNOW's avatar

@ETpro – How’d I know you’d answer this! So, I see this code: this code worked, but I want to make sure it’s right:

DirectoryIndex translation-hu.html

Is there anything more to it than that; I don’t want to mess anything up!

rexacoracofalipitorius's avatar

Yes, there’s a great deal more to it than that, but fortunately you don’t need to know or care about most of it.
Note that .htaccess does not affect the browser in any way. It’s a configuration file for the hosting web server.

I assume you are working with shared hosting, and that your host uses Apache httpd. Apache is by far the most widely used HTTP server, and I know it uses .htaccess files.

@ETpro‘s answer is correct, I’m just adding some information about stopping the listing of directory contents. Stack Overflow seems to think that just having a valid index.html is enough to stop enumeration, but I’m skeptical.

https://wiki.apache.org/httpd/DirectoryListings indicates that ”Options – Indexes” is what you need. I don’t know for sure if this will work in .htaccess or not- it may depend on whether your hosting provider has the proper “AllowOverride” stanza in their httpd configs – if they don’t, hopefully they are sufficiently responsive to make it work for you.

dabbler's avatar

The default page is not determined by the browsers, it’s determined by the server machine.
It is configurable on the host server, but unless you control all those configs you will want to conform to your host’s standards.

phaedryx's avatar

@serenityNOW can you tell us which operating system and server software you’re using? We’re assuming the most popular, but I’d like to verify.

serenityNOW's avatar

@phaedryx – Hey. I use Dreamhost for my hosting needs. I code 99% on Mac OSX. If I’m reading the Dreamhost “features” list, it says: “Operating system: Debian Linux.” Is that the common one?

Thanks, everyone; you all have been so helpful. The work around would have been naming everything “index.html” but then I’d have tons of pages with the same name: massive confusion!

Aside from working out my newest challenge (posted minutes ago) I want to make custom 404’s and protect my image folders. Fun!

rexacoracofalipitorius's avatar

@serenityNOW Debian Linux is what I use for pretty much everything. The host’s OS is really only relevant if you have a VPS or dedicated host, not if you use shared hosting.

Dreamhost definitely uses Apache, but possibly not exclusively. To find out whether Apache is running on your system, you can enter:
apache2ctl status
at a shell prompt. If apache is installed, this will give a status report; otherwise you’ll get an error.
I saw on the “features” page that Dreamhost offers “full shell access” to shared hosting accounts, but not details on how to use it- so hopefully you already know how.

jessibrown's avatar

You have to redirect it using your control panel settings or upload a .ht access file to your website public folder to short out this issue. well, i have redirected my xxx[dot]com/index.html page to xxx[dot]com.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther