Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2012, 02:39 PM   PM User | #1
listerdl
Regular Coder

 
Join Date: Mar 2011
Posts: 157
Thanks: 7
Thanked 0 Times in 0 Posts
listerdl is an unknown quantity at this point
What do you do with empty directories?

What I mean is - I have some paths that are like this:

my-site.com/folder/content.html

But the /folder/ has no content. I know that I can add an index.html file there but is there a way redirect users away from looking in an empty folder?

I guess .301 htaccess can do that as can a javascript redirect - but is there a third way? Just wondering what you guys would do.....
listerdl is offline   Reply With Quote
Old 12-07-2012, 05:00 PM   PM User | #2
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,007
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
If you don't want to have to create an index file in each directory then htaccess is really your best (and perhaps only) option.

You can either set a redirect/rewrite to a page that does exist (which, from your question, I assume you know how to do already) or you can specify your default index page so that users can still visit /folder/ and they will see your content.html page.

Setting the default index page to be your contents.html file would look something like this:

Code:
DirectoryIndex content.html
__________________
The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
See Mediocrity in its Infancy
It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
Seek and you shall find... basically:
validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting
Rowsdower! is offline   Reply With Quote
Old 12-09-2012, 11:36 PM   PM User | #3
listerdl
Regular Coder

 
Join Date: Mar 2011
Posts: 157
Thanks: 7
Thanked 0 Times in 0 Posts
listerdl is an unknown quantity at this point
Thanks - appreciate your help. I was just curious to see what other people do
listerdl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:23 PM.


Advertisement
Log in to turn off these ads.