Page 1 of 1

All directories now link back to main page

Posted: Sat Jan 28, 2006 7:56 am
by Guest
We have several subdirectories that we do not want linking back to the main index.php page, but rather showing the default Apache listing of the contents, do I need to edit the htaccess file or something?

http://trenchantonline.com/

Problem directories:
http://trenchantonline.com/webcam/
http://trenchantonline.com/images/

These should be giving me directory listings and they aren't.

Re: All directories now link back to main page

Posted: Sat Jan 28, 2006 9:40 am
by garvinhicking
Please read our FAQ at http://www.s9y.org/11.html#A13

Regards,
Garvin

Posted: Sat Jan 28, 2006 8:48 pm
by Guest
Thanks!

Posted: Sat Jan 28, 2006 8:54 pm
by Guest
Okay nevermind, that didn't work. Now I get page cannot be displayed errors. I've never had to edit .htaccess files for any php CMS-style installation before. Can I ask why all this is necessary for this one?

Posted: Sun Jan 29, 2006 12:29 am
by judebert
It's working for me when I visit your pages. (Sorry I'm so late.)

Serendipity uses a .htaccess file to redirect pretty URLs for search engines. For instance, the pretty /archives/01-Test.html gets converted to the ugly and less-informative index.php?url=/archives/01 without you, your browser, or your search engine ever seeing the ugly version. Serendipity can work without it, but SEO URLs pretty much require .htaccess changes.

The problem is that the .htaccess is valid for its own directory and all subdirectories. If you want a directory outside the Serendipity directories, then the .htaccess doesn't get in your way. If you want a directory *inside* Serendipity's directories, then s9y's .htaccess will redirect it so s9y tries to handle it.

Why does Serendipity want to handle all URLs in its subdirectories? Because we allow "permalinks". You can set any article to have its own URL, completely independent of the pretty URL it gets automatically in the archives/, entries/, or categories/ 'directories'. Any subdirectory of Serendipity will do. We write the .htaccess to automatically redirect <anything>.html to index.php?url=<anything>.html, then look up the link in the database so we can provide what you asked for.

We could avoid that redirection by redirecting only not-found files. But then your browser and search engine get a 401 error, instead of the "success!" message they expect. That hurts your Google rank. Lots.

The workaround, as you have apparently already found, is to put a .htaccess in the subdirectory that allows access. It has precedence for its directory and all ITS subdirectories. So you just set the options you want (like DirectoryIndex) and Bob's your uncle: Serendipity still handles permalinks and pretty URLs, while your subdirectories work as you want.

Posted: Sun Jan 29, 2006 12:54 am
by Guest
I ended up just deleting the root .htaccess file, that's why it is working.

Posted: Sun Jan 29, 2006 2:29 am
by judebert
Try this .htaccess in the subdirectories where you want to access directory contents:

<code>RewriteEngine off
DirectoryIndex <whatever file you want>
Options +Indexes
</code>

The DirectoryIndex line specifies the file to load when someone just uses a directory URL. The .htaccess in your webcam directory should probably be pointing to index.html, and you should omit the line in your images directory.

Posted: Sat Feb 04, 2006 8:47 pm
by Guest
That worked after I removed the <code> and </code> tags and changed <whatever file you want> to index.html